[Lazarus] Is this a bug?

Wolf wv99999 at gmail.com
Fri Jun 16 09:12:31 CEST 2017


The following program produces these two memory leaks:

Heap dump by heaptrc unit
2 memory blocks allocated : 188/208
0 memory blocks freed     : 134/144
2 unfreed memory blocks : 54
True heap size : 32768
True free heap : 32320
Should be : 32448
Call trace for block $00007FFFF7FF31A0 size 27
Call trace for block $00007FFFF7FF30C0 size 27

If the call to "halt;" is commented out, there is no memory leak 
reported. Is this intentional?

program TestBed;

begin
   {run the program with this run parameter: FileToLoad -v -t -r=0.0001}
   write(ParamCount,'  ');
   write(Sizeof(ParamStr(0)),'  ');
   write(Length(ParamStr(0)),'  ');
   writeln(ParamStr(0));

   write(Sizeof(ParamStr(1)),'  ');
   write(Length(ParamStr(1)),'  ');
   writeln(ParamStr(1));

   write(Sizeof(ParamStr(2)),'  ');
   write(Length(ParamStr(2)),'  ');
   writeln(ParamStr(2));

   write(Sizeof(ParamStr(3)),'  ');
   write(Length(ParamStr(3)),'  ');
   writeln(ParamStr(3));

  halt;     // terminating with "halt" causes memory leaks
  end.      // no memory leak

The size of the unfreed memory blocks varies, if the one or the other of 
the program blocks are commented out. There is no discernible 
correlation (to me, at least) between them and the data they are 
supposed to store. Also, the total number of memory blocks allocated and 
later freed varies, the record observed so far is 11 blocks allocated. 
This apparently varies whenever my system is rebooted, and appears to 
have something to do with what else I am running / have been running.

System: Kubuntu 16.4, Lazarus 1.6+dfsg-1 dated 2016-03-01, FPC 3.0.0

wolf




More information about the Lazarus mailing list