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.

Memory leak in MapComposite

See original GitHub issue

We have a method (example below) which is called pretty much constantly (one at a time, varying between 30-160 calls per second). We found that when calling MapComposite (both on the connection and using the global method), we’re seeing a steady increase in memory usage. After around 10-15 minutes of usage in production, we’re getting up to 100% memory (4GB). Removing the mapping causes the memory to remain stable.

Steps to reproduce

public void Process(List<JobDto> jobs)
{
    using (var connection = new NpgsqlConnection(_connectionString))
    {
        connection.Open();
        connection.TypeMapper.MapComposite<JobDto>("job");

        connection.Execute("some_function", new { jobs }); // not necessary for memory increase
    }
}

Further technical details

Npgsql version: 4.0.3 PostgreSQL version: 9.6 Operating system: Linux (production is running in Fargate)

We’re also using Dapper.

Below is a graph of the memory usage (%) over time of the production app (service running in Fargate). The memory drops are when the service is restarted (note each point is the maximum memory the service reached in the time period). image

Thanks! 😃

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rojicommented, Nov 20, 2018

Ouch, OK - thanks for raising this. I’ll take a look at what’s going on.

0reactions
rojicommented, Nov 22, 2018

@scooper91 thanks again, with your repro I indeed found a bug that triggered the leak… PR #2238 fixes this and will be backported to the 4.0.4 release. In the meantime, in order to confirm, you can try out nuget 4.1.0-ci.1423 from our unstable feed - let me know how it goes!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python - Working around memory leaks
My code contains a memory leak which I am completely unable to find (I've look at the other threads on memory leaks).
Read more >
Why is it called a memory leak?
This is analogous to a physical leak as the system memory is slowly lost (like water from a leaky bucket) to useless allocation....
Read more >
What is Memory Leak? How can we avoid?
The consequence of the memory leak is that it reduces the performance of the computer by reducing the amount of available memory.
Read more >
Debug a memory leak in .NET Core
A memory leak may happen when your app references objects that it no longer needs to perform the desired task.
Read more >
Memory leak
In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in...
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