Page 1 of 1

Memory leak when connect fails

Posted: Tue 26 Jan 2010 06:16
by Wade
Delphi 2009
FB 2.1
DBXIDA 2.50.20

If a TSQLConnection fails to connect because the FB server username/password is incorrect, DBXIBA leaks memory.

Very easily reproduced by deliberately using an incorrect password when connecting to a database.

Here's the report of leaked memory:

An unexpected memory leak has occurred. The unexpected small block leaks are:

1 - 12 bytes: Unknown x 3
13 - 20 bytes: TIBCSQLTransactions x 1, TList x 1, TCRConnections x 2, Unknown x 2
21 - 28 bytes: UnicodeString x 1
29 - 36 bytes: UnicodeString x 1
37 - 44 bytes: TIBCSQLTransaction x 1, UnicodeString x 1
45 - 52 bytes: TGDSDatabaseInfo x 1
53 - 60 bytes: UnicodeString x 1
61 - 68 bytes: TGDSTransaction x 2
69 - 76 bytes: TStringList x 4
77 - 84 bytes: UnicodeString x 2, Unknown x 1
85 - 92 bytes: TIBCSQLConnection x 1
117 - 124 bytes: UnicodeString x 1
173 - 188 bytes: TGDSConnection x 1
221 - 236 bytes: Unknown x 1
1981 - 2172 bytes: Unknown x 1

A successfull connection does not generate the memory leak.

Posted: Fri 29 Jan 2010 14:35
by Dimon
Thank you for information. We are investigating this problem. As soon as we solve the problem we will let you know.

Posted: Mon 01 Feb 2010 12:40
by Dimon
I could not reproduce the problem.
Please try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.

Posted: Mon 08 Feb 2010 01:13
by Wade
No need to send an example - it is absolutely simple to reproduce like this:

uses
SqlExpr, DbxIdaDriverLoader;

procedure TForm1.Button1Click(Sender: TObject);
var
SQLCon: TSQLConnection;
begin
ReportMemoryLeaksOnShutdown := True;

SQLCon := TSQLConnection.Create(nil);
try
SQLCon.DriverName := DbxIdaDriverLoader.sBuiltinDriverName;

SQLCon.LoginPrompt := False;
SQLCon.Params.Clear;
SQLCon.Params.Add('User_Name=' + 'XXX');
SQLCon.Params.Add('Password=' + 'YYY');
SQLCon.Params.Add('Database=' + 'C:\ZZZ.FDB');
try
SQLCon.Open;
except
on E:Exception do
Application.ShowException(E);
end;
finally
SQLCon.Free;
end;

Close;
end;

Posted: Tue 09 Feb 2010 10:58
by Plash
This is a bug of dbExpress. It does not free the connection handle if an error occurs.

Posted: Tue 09 Feb 2010 11:08
by Wade
But most of the objects not being freed are Devart classes, so surely you can put in appropriate resource protection to free your own objects - either immediately or at least when shutting down?