Page 1 of 1

Memory leaks?

Posted: Sun 09 Sep 2007 17:07
by yeohray
Using:
Delphi 7, SDAC 4.10.0.10, kbmMemtable 5.52, FastMM 4.78

Test data:
CREATE TABLE test (col1 char(5), col2 nvarchar(128))
INSERT INTO test values ('0', 'ABC')

Code:

Code: Select all

  qryMain.SQL.Text := 'SELECT * FROM test';
  qryMain.Open;

  mem1.LoadFromDataset(qryMain, [mtcpoStructure]);
where
qryMain = TMSQuery using default properties
mem1 = kbmMemtable using default properties

FastMM reports a leak for every TStringField.GetValue for the first column. The strange thing is, if the 2nd field was a char instead of a varchar, no leaks are reported.

Is this something to be concerned about? Thanks.

Posted: Mon 10 Sep 2007 10:39
by Antaeus
The reason of this memory leak is a bug in the TStringField class implementation. This is a standard VCL class.
It looks like kbmMemtable has no avoidance to this problem.
The problem will appear if you replace SDAC components with analogous ADO components.

In order to avoid this problem, you can try use the TVirtualTable component. The Assign method of TVirtualTable serves for loading data from another dataset.

Posted: Mon 10 Sep 2007 15:55
by yeohray
Thanks for looking into this. I will give TVirtualTable a try.

Do you know if this bug is fixed in later versions of Dephi e.g. 2007?

Thanks.

Posted: Tue 11 Sep 2007 08:52
by Antaeus
I tested this issue with Delphi 2007 for Win 32, and have not noticed such memory leak. I used version 11.0.2627.5503.