Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate possible memory leaks (part 1) #54

Merged
merged 63 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
260ca91
perf(memory-leaks): add the Driver project with a sample task to inve…
LSViana Sep 16, 2023
7161b30
perf(memory-leaks): limit amount of documents to create and call Disp…
LSViana Sep 17, 2023
4b43ae4
perf(memory-leaks): add the ITask interface for future tasks
LSViana Sep 19, 2023
f233a35
perf(memory-leaks): implement ITask on the task to create documents
LSViana Sep 19, 2023
90d9741
perf(memory-leaks): update the project entry point
LSViana Sep 19, 2023
b2c609b
perf(memory-leaks): update the Create task to perform tasks slowly to…
LSViana Sep 19, 2023
9df6ea6
perf(memory-leaks): manually dispose DocOptionsNative after using it …
LSViana Sep 19, 2023
17aa58b
perf(memory-leaks): introduce Tasks.Docs.CreateWithOptions
LSViana Sep 19, 2023
0d997b5
perf(memory-leaks): update the project entry point
LSViana Sep 19, 2023
23b771a
perf(memory-leaks): implement destructor in the Doc class
LSViana Sep 20, 2023
1fd14e6
perf(memory-leaks): add GC.SuppressFinalize() to prevent duplicate ca…
LSViana Sep 20, 2023
03bf41e
perf(memory-leaks): introduce Tasks.Docs.ReadId
LSViana Sep 22, 2023
4266abc
perf(memory-leaks): introduce Tasks.Docs.ReadGuid
LSViana Sep 22, 2023
60316d7
perf(memory-leaks): fix Doc.Guid to dispose the native string after r…
LSViana Sep 22, 2023
b4be5f2
perf(memory-leaks): explicitly define the Guid of the document for th…
LSViana Sep 22, 2023
adb17c1
perf(memory-leaks): introduce Tasks.Docs.ReadCollectionId
LSViana Sep 24, 2023
56e22e5
perf(memory-leaks): fix Doc.CollectionId to dispose the native string…
LSViana Sep 24, 2023
8b59b21
perf(memory-leaks): introduce Tasks.Docs.ReadShouldLoad
LSViana Sep 24, 2023
cd51695
perf(memory-leaks): introduce Tasks.Docs.ReadAutoLoad
LSViana Sep 24, 2023
abeb1d0
perf(memory-leaks): introduce Tasks.Docs.Clone
LSViana Sep 24, 2023
2bb7289
perf(memory-leaks): introduce Tasks.Texts.Create
LSViana Sep 26, 2023
f83d3ff
perf(memory-leaks): introduce Tasks.Texts.InsertText
LSViana Sep 26, 2023
77fb8d4
perf(memory-leaks): implement destructor in the InputPointer class
LSViana Sep 26, 2023
0aa6679
perf(memory-leaks): implement destructor in the InputPointerArray class
LSViana Sep 26, 2023
996720f
perf(memory-leaks): introduce Tasks.Texts.InsertEmbed
LSViana Sep 26, 2023
c8c98e8
perf(memory-leaks): introduce Tasks.Texts.RemoveText
LSViana Sep 29, 2023
f3238c5
perf(memory-leaks): introduce Tasks.Texts.FormatText
LSViana Sep 29, 2023
d8e6519
perf(memory-leaks): implement destructor in the TextChunks class
LSViana Sep 29, 2023
829c2d2
perf(memory-leaks): introduce Tasks.Texts.Chunks
LSViana Sep 29, 2023
6fa93ca
perf(memory-leaks): introduce Tasks.Texts.String
LSViana Sep 29, 2023
aed8a67
perf(memory-leaks): introduce Tasks.Texts.Length
LSViana Sep 30, 2023
9b779ca
perf(memory-leaks): implement destructor in the StickyIndex class
LSViana Sep 30, 2023
b9bfe6c
perf(memory-leaks): introduce Tasks.Branches.StickyIndex
LSViana Sep 30, 2023
f62969a
perf(memory-leaks): introduce EventSubscription.Callback property to …
LSViana Oct 3, 2023
5029f2d
perf(memory-leaks): update Observe*() methods to include callbacks wh…
LSViana Oct 3, 2023
4a6b62c
perf(memory-leaks): introduce Tasks.Texts.Observe
LSViana Oct 3, 2023
5806400
Merge branch 'main' into 34-investigate-possible-memory-leaks
LSViana Oct 14, 2023
5dc370a
test(memory-leaks): include development branch in the triggers to the…
LSViana Oct 14, 2023
9e6adb9
perf(memory-leaks): introduce Tasks.Arrays.Create
LSViana Oct 14, 2023
ecaff06
perf(memory-leaks): replace struct type with pointer to read values m…
LSViana Oct 14, 2023
5af9f99
perf(memory-leaks): introduce Tasks.Docs.ObserveAfterTransaction
LSViana Oct 15, 2023
2280afa
fix(memory-leaks): suppress finalizers for handles exposed by Doc.Obs…
LSViana Oct 15, 2023
552bbec
fix(memory-leaks): suppress finalizers for handles exposed by Transac…
LSViana Oct 15, 2023
2bf83ea
test(memory-leaks): format AssociationTypeTests
LSViana Oct 15, 2023
5515da8
fix(memory-leaks): supress finalizers for instances with null handles…
LSViana Oct 15, 2023
1f1c097
perf(memory-leaks): release memory allocated for Input cells on Array…
LSViana Oct 15, 2023
afb225f
perf(memory-leaks): introduce Tasks.Arrays.InsertRange
LSViana Oct 15, 2023
b66d21a
perf(memory-leaks): introduce Tasks.Arrays.RemoveRange
LSViana Oct 15, 2023
4144bb0
perf(memory-leaks): implement destructor in the Output class
LSViana Oct 15, 2023
9880f6e
perf(memory-leaks): introduce Tasks.Arrays.Get
LSViana Oct 15, 2023
b438f50
perf(memory-leaks): introduce Tasks.Arrays.Move
LSViana Oct 15, 2023
fec1699
style(memory-leaks): format Get and RemoveRange Array tasks
LSViana Oct 15, 2023
c6f7639
perf(memory-leaks): implement destructor in the ArrayIterator and Arr…
LSViana Oct 16, 2023
8e2cfb5
perf(memory-leaks): introduce Tasks.Arrays.Iterate
LSViana Oct 16, 2023
0014859
perf(memory-leaks): avoid disposal of Doc instances created from Outp…
LSViana Oct 16, 2023
4b0d29d
perf(memory-leaks): introduce Tasks.Arrays.Length
LSViana Oct 16, 2023
41c7f94
perf(memory-leaks): fix default value of Doc.disposable flag
LSViana Oct 16, 2023
93bcf2b
perf(memory-leaks): introduce Tasks.Arrays.Observe
LSViana Oct 16, 2023
051f54c
fix(memory-leaks): simplify the disposal of Doc instances in Doc.Obse…
LSViana Oct 16, 2023
ea2305e
perf(memory-leaks): introduce Tasks.Docs.ObserveClear
LSViana Oct 16, 2023
e02419b
perf(memory-leaks): introduce Tasks.Docs.ObserveUpdatesV1
LSViana Oct 16, 2023
e31cefc
perf(memory-leaks): introduce Tasks.Docs.ObserveUpdatesV2
LSViana Oct 16, 2023
a4f5798
perf(memory-leaks): introduce Tasks.Docs.ObserveSubDocs
LSViana Oct 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- 'main'
- '34-investigate-possible-memory-leaks'

jobs:
test:
Expand Down
6 changes: 6 additions & 0 deletions Tests/YDotNet.Tests.Driver/Abstractions/ITask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace YDotNet.Tests.Driver.Abstractions;

public interface ITask
{
Task Run();
}
5 changes: 5 additions & 0 deletions Tests/YDotNet.Tests.Driver/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// See https://aka.ms/new-console-template for more information

using YDotNet.Tests.Driver.Tasks.Docs;

new ObserveSubDocs().Run();
40 changes: 40 additions & 0 deletions Tests/YDotNet.Tests.Driver/Tasks/Arrays/Create.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using YDotNet.Document;
using YDotNet.Tests.Driver.Abstractions;

namespace YDotNet.Tests.Driver.Tasks.Arrays;

public class Create : ITask
{
public Task Run()
{
var count = 0;

// Create many documents
while (count < 1_000_000)
{
// After 1s, stop and show the user the amount of documents
if (count > 0)
{
Console.WriteLine("Status Report");
Console.WriteLine($"\tArrays:\t{count}");
Console.WriteLine();
}

if (count % 1_000 == 0)
{
Thread.Sleep(millisecondsTimeout: 15);
}

// Create many documents
for (var i = 0; i < 100; i++)
{
var doc = new Doc();
doc.Array($"sample-{i}");
doc.Dispose();
count++;
}
}

return Task.CompletedTask;
}
}
52 changes: 52 additions & 0 deletions Tests/YDotNet.Tests.Driver/Tasks/Arrays/Get.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using YDotNet.Document;
using YDotNet.Document.Cells;
using YDotNet.Tests.Driver.Abstractions;

namespace YDotNet.Tests.Driver.Tasks.Arrays;

public class Get : ITask
{
public Task Run()
{
var count = 0;

// Create many documents
while (count < 1_000_000)
{
// After 1s, stop and show the user the amount of documents
if (count > 0)
{
Console.WriteLine("Status Report");
Console.WriteLine($"\tArrays:\t{count}");
Console.WriteLine();
}

if (count % 1_000 == 0)
{
Thread.Sleep(millisecondsTimeout: 15);
}

// Create many documents
for (var i = 0; i < 100; i++)
{
var doc = new Doc();
var array = doc.Array($"sample-{i}");

var transaction = doc.WriteTransaction();
array.InsertRange(
transaction, index: 0, new[]
{
Input.Long(value: 2469L),
Input.Boolean(value: false)
});
array.Get(transaction, index: 1);
transaction.Commit();

doc.Dispose();
count++;
}
}

return Task.CompletedTask;
}
}
46 changes: 46 additions & 0 deletions Tests/YDotNet.Tests.Driver/Tasks/Arrays/InsertRange.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using YDotNet.Document;
using YDotNet.Document.Cells;
using YDotNet.Tests.Driver.Abstractions;

namespace YDotNet.Tests.Driver.Tasks.Arrays;

public class InsertRange : ITask
{
public Task Run()
{
var count = 0;

// Create many documents
while (count < 1_000_000)
{
// After 1s, stop and show the user the amount of documents
if (count > 0)
{
Console.WriteLine("Status Report");
Console.WriteLine($"\tArrays:\t{count}");
Console.WriteLine();
}

if (count % 1_000 == 0)
{
Thread.Sleep(millisecondsTimeout: 15);
}

// Create many documents
for (var i = 0; i < 100; i++)
{
var doc = new Doc();
var array = doc.Array($"sample-{i}");

var transaction = doc.WriteTransaction();
array.InsertRange(transaction, index: 0, new[] { Input.Long(value: 2469L) });
transaction.Commit();

doc.Dispose();
count++;
}
}

return Task.CompletedTask;
}
}
53 changes: 53 additions & 0 deletions Tests/YDotNet.Tests.Driver/Tasks/Arrays/Iterate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using YDotNet.Document;
using YDotNet.Document.Cells;
using YDotNet.Tests.Driver.Abstractions;

namespace YDotNet.Tests.Driver.Tasks.Arrays;

public class Iterate : ITask
{
public Task Run()
{
var count = 0;

// Create many documents
while (count < 1_000_000)
{
// After 1s, stop and show the user the amount of documents
if (count > 0)
{
Console.WriteLine("Status Report");
Console.WriteLine($"\tArrays:\t{count}");
Console.WriteLine();
}

if (count % 1_000 == 0)
{
Thread.Sleep(millisecondsTimeout: 15);
}

// Create many documents
for (var i = 0; i < 100; i++)
{
var doc = new Doc();
var array = doc.Array($"sample-{i}");

var transaction = doc.WriteTransaction();
array.InsertRange(
transaction, index: 0, new[]
{
Input.Long(value: 2469L),
Input.Boolean(value: false),
Input.Undefined()
});
array.Iterate(transaction).ToArray();
transaction.Commit();

doc.Dispose();
count++;
}
}

return Task.CompletedTask;
}
}
47 changes: 47 additions & 0 deletions Tests/YDotNet.Tests.Driver/Tasks/Arrays/Length.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using YDotNet.Document;
using YDotNet.Document.Cells;
using YDotNet.Tests.Driver.Abstractions;

namespace YDotNet.Tests.Driver.Tasks.Arrays;

public class Length : ITask
{
public Task Run()
{
var count = 0;

// Create many documents
while (count < 1_000_000)
{
// After 1s, stop and show the user the amount of documents
if (count > 0)
{
Console.WriteLine("Status Report");
Console.WriteLine($"\tArrays:\t{count}");
Console.WriteLine();
}

if (count % 1_000 == 0)
{
Thread.Sleep(millisecondsTimeout: 15);
}

// Create many documents
for (var i = 0; i < 100; i++)
{
var doc = new Doc();
var array = doc.Array($"sample-{i}");

var transaction = doc.WriteTransaction();
array.InsertRange(transaction, index: 0, new[] { Input.Long(value: 2469L) });
var _ = array.Length;
transaction.Commit();

doc.Dispose();
count++;
}
}

return Task.CompletedTask;
}
}
53 changes: 53 additions & 0 deletions Tests/YDotNet.Tests.Driver/Tasks/Arrays/Move.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using YDotNet.Document;
using YDotNet.Document.Cells;
using YDotNet.Tests.Driver.Abstractions;

namespace YDotNet.Tests.Driver.Tasks.Arrays;

public class Move : ITask
{
public Task Run()
{
var count = 0;

// Create many documents
while (count < 1_000_000)
{
// After 1s, stop and show the user the amount of documents
if (count > 0)
{
Console.WriteLine("Status Report");
Console.WriteLine($"\tArrays:\t{count}");
Console.WriteLine();
}

if (count % 1_000 == 0)
{
Thread.Sleep(millisecondsTimeout: 15);
}

// Create many documents
for (var i = 0; i < 100; i++)
{
var doc = new Doc();
var array = doc.Array($"sample-{i}");

var transaction = doc.WriteTransaction();
array.InsertRange(
transaction, index: 0, new[]
{
Input.Long(value: 2469L),
Input.Boolean(value: false),
Input.Undefined()
});
array.Move(transaction, sourceIndex: 0, targetIndex: 2);
transaction.Commit();

doc.Dispose();
count++;
}
}

return Task.CompletedTask;
}
}
49 changes: 49 additions & 0 deletions Tests/YDotNet.Tests.Driver/Tasks/Arrays/Observe.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using YDotNet.Document;
using YDotNet.Document.Cells;
using YDotNet.Tests.Driver.Abstractions;

namespace YDotNet.Tests.Driver.Tasks.Arrays;

public class Observe : ITask
{
public Task Run()
{
var count = 0;

// Create many documents
while (count < 1_000_000)
{
// After 1s, stop and show the user the amount of documents
if (count > 0)
{
Console.WriteLine("Status Report");
Console.WriteLine($"\tArrays:\t{count}");
Console.WriteLine();
}

if (count % 1_000 == 0)
{
Thread.Sleep(millisecondsTimeout: 15);
}

// Create many documents
for (var i = 0; i < 100; i++)
{
var doc = new Doc();
var array = doc.Array($"sample-{i}");

var subscription = array.Observe(_ => { });

var transaction = doc.WriteTransaction();
array.InsertRange(transaction, index: 0, new[] { Input.Long(value: 2469L) });
transaction.Commit();

array.Unobserve(subscription);
doc.Dispose();
count++;
}
}

return Task.CompletedTask;
}
}
Loading