Subject | Memory leak |
---|---|
Author | Dennis McFall |
Post date | 2002-08-09T21:40:07Z |
I am losing several MB of memory (Task Manager MemUsage) every time I call
Open with a TIB_Cursor. After I call Close, the MemUsage stays near its peak.
Delphi 6 Pro, IBO 4.2 (IB_Connection, IB_Cursor), W2K (local/network, makes
no difference):
For example, if I add strings to a TStringList by alternately clicking
ButtonSetList and ButtonFreeList, the MemUsage goes like this, which is as
it should be (the actual code is just below the MemUsage listing):
Base MemUsage: 10916
SetList: MU = 11108
FreeList: MU = 10916
SetList: MU = 11108
FreeList: MU = 10916
SetList: MU = 11108
FreeList: MU = 10916
procedure TfrmMain.ButtonSetListClick(Sender: TObject);
var n : integer;
begin
aList := TStringList.create;
for n := 0 to 4678 do aList.Add('SomeFirst SomeLastName');
end
procedure TfrmMain.ButtonFreeListClick(Sender: TObject);
begin
aList.Clear;
aList.Free;
end;
--------------------------------------
But if I use a TIB_Cursor to select 4678 records, and alternately click
ButtonSelectNames and ButtonFreeList, the MemUsage goes like
this (MemUsage goes up by 9700KB on each execution of the select, and goes
down 300KB when the stringlist is freed). The computer becomes unusable,
and I have to reboot the application to release the memory:
Base MemUsage: 11624
SetList: MU = 23168
FreeList: MU = 21100
SetList: MU = 30828
FreeList: MU = 30524
SetList: MU = 40292
FreeList: MU = 40140
SetList: MU = 49840
FreeList: MU = 49504
procedure TfrmMain.ButtonSelectNamesClick(Sender: TObject);
begin
aList := TStringList.create;
n := 0;
with TIB_Cursor.create(nil) do try
IB_Connection:=DModOne.Connection1;
IB_Transaction:=DModOne.Transaction1;
SQL.Add(' SELECT LASTNAME, FIRSTNAME FROM PERSONS WHERE NAME_OID <
120000 ORDER BY LASTNAMEUPPER');
Open;
if not eof then while not eof do begin
aList.Add(Fields[0].AsString + ' ' + Fields[1].AsString );
Next;
end;
finally
Close;
free;
end;
end;
procedure TfrmMain.ButtonFreeListClick(Sender: TObject);
begin
aList.Clear;
aList.Free;
end;
Is there some way to release a buffer somewhere, or what I am doing [wrong]
to cause this memory loss problem? It is happening A LOT for me
(everywhere I do a SELECT)....
TIA,
Dennis McFall
Open with a TIB_Cursor. After I call Close, the MemUsage stays near its peak.
Delphi 6 Pro, IBO 4.2 (IB_Connection, IB_Cursor), W2K (local/network, makes
no difference):
For example, if I add strings to a TStringList by alternately clicking
ButtonSetList and ButtonFreeList, the MemUsage goes like this, which is as
it should be (the actual code is just below the MemUsage listing):
Base MemUsage: 10916
SetList: MU = 11108
FreeList: MU = 10916
SetList: MU = 11108
FreeList: MU = 10916
SetList: MU = 11108
FreeList: MU = 10916
procedure TfrmMain.ButtonSetListClick(Sender: TObject);
var n : integer;
begin
aList := TStringList.create;
for n := 0 to 4678 do aList.Add('SomeFirst SomeLastName');
end
procedure TfrmMain.ButtonFreeListClick(Sender: TObject);
begin
aList.Clear;
aList.Free;
end;
--------------------------------------
But if I use a TIB_Cursor to select 4678 records, and alternately click
ButtonSelectNames and ButtonFreeList, the MemUsage goes like
this (MemUsage goes up by 9700KB on each execution of the select, and goes
down 300KB when the stringlist is freed). The computer becomes unusable,
and I have to reboot the application to release the memory:
Base MemUsage: 11624
SetList: MU = 23168
FreeList: MU = 21100
SetList: MU = 30828
FreeList: MU = 30524
SetList: MU = 40292
FreeList: MU = 40140
SetList: MU = 49840
FreeList: MU = 49504
procedure TfrmMain.ButtonSelectNamesClick(Sender: TObject);
begin
aList := TStringList.create;
n := 0;
with TIB_Cursor.create(nil) do try
IB_Connection:=DModOne.Connection1;
IB_Transaction:=DModOne.Transaction1;
SQL.Add(' SELECT LASTNAME, FIRSTNAME FROM PERSONS WHERE NAME_OID <
120000 ORDER BY LASTNAMEUPPER');
Open;
if not eof then while not eof do begin
aList.Add(Fields[0].AsString + ' ' + Fields[1].AsString );
Next;
end;
finally
Close;
free;
end;
end;
procedure TfrmMain.ButtonFreeListClick(Sender: TObject);
begin
aList.Clear;
aList.Free;
end;
Is there some way to release a buffer somewhere, or what I am doing [wrong]
to cause this memory loss problem? It is happening A LOT for me
(everywhere I do a SELECT)....
TIA,
Dennis McFall