I have some questions about Linux & ARC and I'm hoping some experts can share their expertise because I'm not...

I have some questions about Linux & ARC and I'm hoping some experts can share their expertise because I'm not understand the results I'm seeing.

For the first example, I have a simple console application making use of Devart's Postgres database controls...

This code just chews up more and more memory and makes more and more connections to the postgres server until the server cannot accept anymore connections. This appears to be because 'free' no longer actually works.

I appreciate that .disposeOf works in this code, but I'm trying to understand if the vendor really needs to go and replace every 'free' with disposeOf (and in theory we do as well) and why this particular code which to me seems simple doesn't ever kill any of the objects created.

I appreciate databases would normally be used in thread pools, I pulled this out of a thread pool to try and debug the underlying object due to the memory leak in the thread pool.

program TPgMemLeak2;

{$APPTYPE CONSOLE}

{$R *.res}


uses
System.SysUtils,
System.Classes,
PgAccess;


procedure newTask( value: integer );
var
pgConnection: TPgConnection;
pgQuery: TPgQuery;
begin
pgConnection := TPgConnection.Create(nil);
pgConnection.Server := server;
pgConnection.Username := user;
pgConnection.Password := password;
pgConnection.Database := Database;
pgConnection.Pooling := false;
pgQuery := TPgQuery.Create(nil);
pgQuery.Connection := pgConnection;
pgQuery.SQL.Text := 'select * from ' + TableName;
pgQuery.Open;
pgQuery.free;
pgConnection.free;
sleep(10);
end;

var
i: integer;
begin
try

writeLn('Starting...');

for i := 0 to 1000 do
begin
newTask( i );
sleep(10);
end;

writeLn('Freeing...');

except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.

Comments