Everytime you open and close an XML file more safe array memory gets
allocated until you get a run out of virtual memory message. I have provided
a report from Memory Sleuth showing the final allocation of Safe Array after
just 3 closes/opens. The graphs shows the safe allocation as follows:
Event 1: 600,000 - First close and open of the file
Event 2: 1,200,000 - Second close and open of the file
Event 3: 1,800,000 - Third close and open of the file
I would appreciate any help on solving this problem.... I am using the XML
file to monitor multiple mainframe systems and can't complete the job until
this is solved.
Three timer events occurred and here is the results of Sleuth Code Watch:
Memory types view for C:\Program Files\Borland\Delphi6\Projects\Bug
Report\TClientDataSet\iClientDataSet.exe
View:Memory Types Used In Session.
View:Memory Types Used In Session, sorted by Type, Ascending.
Type # of Ptrs Allocated Peak Memory (Bytes) Peak Show Events
Global Memory 0 8 0 10,596 Yes 24
OLE String Memory 54 55 2,040 2,082 Yes 162
Safe Array 3 3 1,815,156 1,815,156 Yes 3
Safe Array Descriptor 3 3 72 72 Yes 3
VCL Memory 5 382 144 21,788 Yes 2,193
VCL Virtual Memory 0 3 0 49,152 Yes 112
Virtual Memory 1 2 4,096 69,632 Yes 3
Windows Heap Memory 1 3 2,048 3,712 Yes 7
HTML file generated on Tuesday, October 30, 2001, at 11:38 AM by
TurboPower Sleuth CodeWatch.
Note: The Safe Array memory goes up by 600,000 bytes each iteration. It
looks as if the file is being appended each time you close and open it. What
up with that?
************************ Form *******************************
object Form1: TForm1
Left = 473
Top = 232
Width = 291
Height = 170
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 96
Top = 56
Width = 32
Height = 13
Caption = 'Label1'
end
object Timer1: TTimer
Interval = 10000
OnTimer = Timer1Timer
Left = 8
end
object ClientDataSet1: TClientDataSet
Aggregates = <>
FileName =
'C:\Program Files\Borland\Delphi6\Projects\Bug Report\TClientData'
+
'Set\DataFile.XML'
Params = <>
Left = 40
end
end
************************ Program *******************************
program iClientDataSet;
uses
Forms,
cClientDataSet in 'cClientDataSet.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
************************ Unit *******************************
unit cClientDataSet;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, DB, DBClient, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
ClientDataSet1: TClientDataSet;
Label1: TLabel;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
iCount: Integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
try
inc(iCount);
label1.Caption := IntToStr(iCount);
Timer1.Enabled := False;
ClientDataSet1.Close;
ClientDataSet1.Open;
finally
Timer1.Enabled := True;
end;
end;