Memory leaks with with massive queries

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Posts: 5
Joined: Wed 21 Jul 2010 13:20

Memory leaks with with massive queries

Post by pac » Wed 21 Jul 2010 14:08

Hi, I'm using Devart.Data.PostgreSql v4.95.146 (Express Edition) to stress a server with a simple query with random parameter's values.

The query is executed with a DbDataReader, obtaining nearly 1500 queries/second. But after 2 hours of running time, the memory's usage goes up from 45 MB to 1.5 GB, even at a visible pace with Process Explorer utility and its Performance Graph.

The simplified code looks like this:

Code: Select all

var connectionString = "...";
using (var connection = new PgSqlConnection(connectionString) { Unicode = true })
var sql = "select field from table where f1=? and f2=?;"
using (var command = new PgSqlCommand(sql, connection);
command.Parameters.AddRange(GetParameters()); // DbParameter[] GetParameters () {...}

while (true)
SetParameterValues(command.Parameters); // void SetParameterValues (DbParameterCollection parameters) {...}
using (var reader = command.ExecuteReader(CommandBehavior.SingleResult))
var count = 0L;
while (reader.Read())
For longer periods we got OutOfMemory exceptions with this callstack:

Code: Select all

   in Devart.Common.Utils.SetWeakTarget(WeakReference& weakReference, Object target)
   in Devart.Common.DbReferenceCollection.AddItem(Object value, Int32 tag)
   in Devart.Common.DbReferenceCollection.Add(Object value, Int32 tag)
   in Devart.Common.DbConnectionInternal.a(Object A_0, Int32 A_1)
   in Devart.Common.DbConnectionBase.a(DbDataReader A_0)
   in Devart.Data.PostgreSql.PgSqlCommand.AddDataReader(DbDataReader reader)
   in Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
   in Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
   in System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   in ...
Any ideas?

Thanks for your support.

Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 23 Jul 2010 17:19

Could you please specify the exact scripts executed? If possible, please send us a complete small sample with which the problem can be reproduced. We couldn't reproduce it with simple tables.

Post Reply