Memory leak in TIBCQuery parameters

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
[email protected]
Posts: 1
Joined: Tue 12 Apr 2016 13:21

Memory leak in TIBCQuery parameters

Post by [email protected] » Tue 12 Apr 2016 13:47

Hello,
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;
After closing the program, there is a memory leak (I use EurekaLog). This is the call stack:

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;
This may be present in previous versions of IBDAC, I do not know exactly when this leak appeared.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Memory leak in TIBCQuery parameters

Post by ViktorV » Wed 13 Apr 2016 06:30

We have already fixed this issue. The fix will be included in the next IBDAC build.

Post Reply