-
Notifications
You must be signed in to change notification settings - Fork 877
Closed as duplicate of#3069
Copy link
Description
Steps to reproduce
Update pg_hba.conf to trust the connection.
host all all all trust
public class Program
{
public static void Main(string[] args)
{
for (var i = 0; i < 1000; i++)
{
Npgsql.NpgsqlConnection.ClearAllPools();
var conStr = $"User ID=docker;Password={i};Host=postgres;Port=5432;Database=postgres;Connection Idle Lifetime=10;Connection Pruning Interval=5";
using var connection = new NpgsqlConnection(conStr);
connection.Open();
using var cmd = new NpgsqlCommand("select 1", connection);
cmd.Prepare();
using var reader = cmd.ExecuteReader();
while (reader.Read())
{
// do nothing
}
connection.Close();
Thread.Sleep(5);
}
}
}
The issue
All objects related to every opened connection are being kept in memory, even after executing GC and waiting a couple of minutes.
As you can verify below, the objects are kept in memory, most of them are moved to GC GEN 2.

The image below shows the allocation of the GC.

Further technical details
Npgsql version: 4.1.5
PostgreSQL version: 13
Operating system: Container Linux .net core 3.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels