question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Native memory leak when inserting repeatedly

See original GitHub issue

CouchbaseLite/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

CouchbaseMemoryLeak.zip

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
borrrdencommented, Dec 11, 2019

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).

1reaction
Sandychuang8commented, Dec 11, 2019

Thanks for reporting. We found a leak and filed a ticket 580

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found