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.
Memory leak when connect fails
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;
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;