Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2005-10

Memory leak in concatenating variants

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Franz Schober

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.

Reply by email