StringHashList, Remove and memory leaks
Original Reporter info from Mantis: Dibo
-
Reporter name: Krzysztof Dibowski
Original Reporter info from Mantis: Dibo
- Reporter name: Krzysztof Dibowski
Description:
Hi,
I have doubts as to free resources by StringHashList. Clear method works correctly, but when I delete all Items by Remove method, module heaptrc notify me about unfreed memory blocks:
Heap dump by heaptrc unit
1502 memory blocks allocated : 1040255/1045232
1501 memory blocks freed : 1040231/1045208
1 unfreed memory blocks : 24
True heap size : 1409024
True free heap : 1408864
Should be : 1408888
Call trace for block $00007FFFF05FC3B0 size 24
$00000000006FD99F line 290 of stringhashlist.pas
$00000000006FD2B5 line 125 of stringhashlist.pas
$00000000006FD147 line 83 of stringhashlist.pas
$00000000004C77C3 line 59 of unit1.pas
$000000000060342D line 2227 of include/control.inc
$00000000006581DE line 72 of include/buttoncontrol.inc
$00000000006588F8 line 164 of include/buttons.inc
$0000000000658F05 line 331 of include/buttons.inc
Here is example:
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ private declarations }
FHashList: TStringHashList;
public
{ public declarations }
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FHashList := TStringHashList.Create(False);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FHashList.Add('S' + IntToStr(FHashList.Count));
end;
procedure TForm1.FormDestroy(Sender: TObject);
var
q: Integer;
begin
for q:=0 to FHashList.Count-1 do
FHashList.Remove('S' + IntToStr(q));
FHashList.Free;
end;
I noticed that the module StringHashList has changed. I downloaded it from SVN but the problem still occurs.
Regards
Mantis conversion info:
- Mantis ID: 15755
- Version: 0.9.28.2
- Fixed in version: 0.9.29 (SVN)
- Fixed in revision: 24018 (#75af880b)
- Target version: 1.0.0
- LazTarget: 1.0