[fpc-devel] Memory leak in concatenating variants

Franz Schober fpc_devel at firmos.at
Thu Oct 27 14:49:07 CEST 2005


This bug demo program compiled with fpc 2.0.1 stable under linux uses
megabytes of memory.

 

Concatenating a string and a variant causes the problem.

 

Thank you,

Franz Schober

 

 

 

 

program heapstate;

 

 

uses  Classes,sysutils;

 

 

procedure DumpHeapState;

var HS:THeapStatus;

     o:string;

begin

 HS:=GetHeapStatus;

 o:=Format('HEAP STATE TA/TF %d/%d  TC/TU %d/%d UU %d  OH
%d',[hs.TotalAllocated,hs.TotalFree,hs.TotalCommitted,hs.TotalUncommitted,hs
.Unused,hs.Overhead]);

 writeln(o);

end;

 

 

var  i:integer;

     s,s2:string;

     v:variant;

begin

 for i:=1 to 2000000000 do begin

  v:='10';

  s:='  leak  '+v;

  if i mod 100000=0 then begin

   DumpHeapState;

  end;

 end;

 readln;

end.

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20051027/6af352f5/attachment.html>


More information about the fpc-devel mailing list