I have found a memory leak when using TIBCQuery parameters. IBDAC version 5.6.20 using Firebird. Consider the following code:
Code: Select all
Q := TIBCQuery.Create(nil);
try
Q.Transaction := AConnection.DefaultTransaction;
Q.Connection := AConnection;
Q.SQL.Text := ' select T.* from TABLE T where T.NAME = :NAME ';
Q.ParamByName('NAME').AsString := AName;
Q.Open;
//process query result...
finally
Q.Free;
end;
Unit |Class |Procedure/Method |Line |
CLRClasses |Marshal |AllocHGlobal |427[1]
IBCClasses |TIBCParamDesc |AllocBuffer |5616[74]
IBCClasses |TIBCParamDesc |SetArraySize |6278[6]
DBAccess |TCustomDASQL |AssignParam |14643[8]
IBC |TIBCSQL |AssignParam |3436[1]
DBAccess |TCustomDASQL |WriteParams |14557[14]
DBAccess |TCustomDADataSet |OpenCursor |7970[42]
Data.DB |TDataSet |SetActive |
DBAccess |TCustomDADataSet |SetActive |7913[4]
Data.DB |TDataSet |Open |
Now, if I change the code so I specify ParamType and DataType for the parameter, the memory leak goes away:
Code: Select all
Q := TIBCQuery.Create(nil);
try
Q.Transaction := AConnection.DefaultTransaction;
Q.Connection := AConnection;
Q.SQL.Text := ' select T.* from TABLE T where T.NAME = :NAME ';
Q.ParamByName('NAME').ParamType := ptInput;
Q.ParamByName('NAME').DataType := ftString;
Q.ParamByName('NAME').AsString := AName;
Q.Open;
//process query result...
finally
Q.Free;
end;