Skip to content

Memory leak in MapComposite #2234

@scooper91

Description

@scooper91

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! :)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions