View Issue Details

IDProjectCategoryView StatusLast Update
0015755LazarusLCLpublic2011-12-01 11:23
ReporterKrzysztof DibowskiAssigned ToVincent Snijders 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.28.2Product Build 
Target Version1.0.0Fixed in Version0.9.29 (SVN) 
Summary0015755: StringHashList, Remove and memory leaks
DescriptionHi,

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
TagsNo tags attached.
Fixed in Revision24018
LazTarget1.0
WidgetsetGTK 2
Attached Files
  • shl_leak.diff (333 bytes)
    Index: stringhashlist.pas
    ===================================================================
    --- stringhashlist.pas	(revision 23916)
    +++ stringhashlist.pas	(working copy)
    @@ -129,7 +129,6 @@
     var
       I: Integer;
     begin
    -  if fCount = 0 then exit;
       for I:= 0 to fCount -1 do
         Dispose(fList[I]);
       if FList<>nil then begin
    
    shl_leak.diff (333 bytes)

Activities

2010-03-12 11:46

 

shl_leak.diff (333 bytes)
Index: stringhashlist.pas
===================================================================
--- stringhashlist.pas	(revision 23916)
+++ stringhashlist.pas	(working copy)
@@ -129,7 +129,6 @@
 var
   I: Integer;
 begin
-  if fCount = 0 then exit;
   for I:= 0 to fCount -1 do
     Dispose(fList[I]);
   if FList<>nil then begin
shl_leak.diff (333 bytes)

cobines

2010-03-12 11:46

reporter   ~0035314

Uploaded patch to fix the issue.

Vincent Snijders

2010-03-15 21:43

manager   ~0035600

Thanks for the patch.

Issue History

Date Modified Username Field Change
2010-02-13 13:15 Krzysztof Dibowski New Issue
2010-02-13 13:15 Krzysztof Dibowski Widgetset => GTK 2
2010-03-12 10:21 Vincent Snijders LazTarget => 1.0
2010-03-12 10:21 Vincent Snijders Status new => acknowledged
2010-03-12 10:21 Vincent Snijders Target Version => 1.0.0
2010-03-12 11:46 cobines File Added: shl_leak.diff
2010-03-12 11:46 cobines Note Added: 0035314
2010-03-15 21:43 Vincent Snijders Fixed in Revision => 24018
2010-03-15 21:43 Vincent Snijders Status acknowledged => resolved
2010-03-15 21:43 Vincent Snijders Fixed in Version => 0.9.29 (SVN)
2010-03-15 21:43 Vincent Snijders Resolution open => fixed
2010-03-15 21:43 Vincent Snijders Assigned To => Vincent Snijders
2010-03-15 21:43 Vincent Snijders Note Added: 0035600
2011-12-01 11:23 Marc Weustink Status resolved => closed