Native memory leak when inserting repeatedly
See original GitHub issueCouchbaseLite/2.6.0 (.NET; UWP 10.0.18363.476; Dell Inc. XPS 15 9570) Build/129 LiteCore/2.6.0 (2193) Commit/e715812a
Library Version
2.6.0 (2193)
.NET Runtime
UWP 10.0.18363.476
Operating System / Device Details
Windows 10 Enterprise
Expected behavior
The reproduction project should run indefinitely without running out of memory.
Actual behavior
The native heap size climbs rapidly as the reproduction project continues to insert records. This can be seen when running the project in Visual Studio 2019 and observing the diagnostic tools.
Steps To Reproduce
Run the supplied reproduction project. The reproduction project does the following:
var directoryPath = Path.GetTempPath();
while (true)
{
// asynchronously insert a record into the database
await Task.Run(() =>
{
var timestamp = DateTime.UtcNow;
// create the record to be stored
var record = new Dictionary<string, object>()
{
{ "Timestamp", timestamp.Ticks },
{ "Value", "test" }
};
var config = new DatabaseConfiguration()
{
Directory = Path.Combine(directoryPath)
};
// create the database
using (var db = new Database(name: "MyDatabase", config))
{
// convert the record to a mutable document and save it
using (var document = new MutableDocument(timestamp.Ticks.ToString(), record))
{
db.Save(document);
}
}
}).ConfigureAwait(false);
// wait briefly before inserting another record
await Task.Delay(10).ConfigureAwait(false);
}
Reproduction Project
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
Hunting Java Memory Leaks
In this post, I'll explain how and why memory leaks occur in Java and outline an ... Native memory leaks: associated with any...
Read more >Native Heap related Memory Leak in .NET Application
So I'm pretty familiar with capturing memory dumps and searching them with WinDbg + SOS.
Read more >Java – Debugging Native Memory Leaks
But if RSS is constantly increasing with no increase in heap and non-heap memory, then you have a native memory leak.
Read more >Find, Fix, and Avoid Memory Leaks in C# .NET: 8 Best ...
Investigate the New-Created-Instances, they are probably memory leaks. Examine the “path to GC Root” and try to understand why those objects ...
Read more >Native memory leak example
One particular memory leak affecting Java deployments out there is particularly nasty to troubleshoot. This leak would happen in native ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To add some more info, you will only see this leak by repeatedly opening and closing the database and saving documents as you do. If you do not open the database in a loop you will not see the issue (at least not nearly to the extent it shows in your repro, where each leaked object has about 32k inside).
Thanks for reporting. We found a leak and filed a ticket 580