Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

ID: 16917, TClientDataSet SafeArray Patch For Memory Leak

by Kenneth Davis Email: Anonymous

I found that safearray memory was not being released when loading a new XML file. Depending on how many files you were loading and the size, it would finally give me a short on virtual storage message.
Download Details
FTP  download also available 0 bytes
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 6.0  to 6.0 14 downloads
Copyright: No significant restrictions

Size: 0 bytes
Updated on Tue, 06 Nov 2001 13:03:25 GMT
Originally uploaded on Tue, 06 Nov 2001 13:04:47 GMT
Fix: Source/VCL/DSIntf.pas

Before I applied the patch, I was getting a "DISP_E_ARRAYISLOCKED" return code, which lead me to use the SafeArrayUnAccessData. With the patch they both get a "S_OK" and memory slueth show the safearry memory being allocated and deallocated, when each new file is openned and closed.

procedure FreeDataPacket(var DataPacket: TDataPacket);
if Assigned(DataPacket) then
SafeArrayUnAccessData(DataPacket); //Patched
DataPacket := nil;

If you want to recreate the bug do the following:

1 - Timer run it every second.
1 - TClientDataset set the clientdataset to a large XML file.

Depending on the size of the file, you should get a virtual storage message in about an hour or two.

procedure TForm1.Timer1Timer(Sender: TObject);
Timer1.Enabled := False;
Timer1.Enabled := True;

The same thing happens if you use a stream.

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03