Memory leak in MapComposite
See original GitHub issueWe 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).
Thanks! 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Ouch, OK - thanks for raising this. I’ll take a look at what’s going on.
@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!