Memory leak when connect fails

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for InterBase & Firebird in Delphi and C++Builder
Post Reply
Wade
Posts: 31
Joined: Sun 03 Jan 2010 06:04

Memory leak when connect fails

Post by Wade » Tue 26 Jan 2010 06:16

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.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 29 Jan 2010 14:35

Thank you for information. We are investigating this problem. As soon as we solve the problem we will let you know.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 01 Feb 2010 12:40

I could not reproduce the problem.
Please try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.

Wade
Posts: 31
Joined: Sun 03 Jan 2010 06:04

Post by Wade » Mon 08 Feb 2010 01:13

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;

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 09 Feb 2010 10:58

This is a bug of dbExpress. It does not free the connection handle if an error occurs.

Wade
Posts: 31
Joined: Sun 03 Jan 2010 06:04

Post by Wade » Tue 09 Feb 2010 11:08

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?

Post Reply