[fpc-pascal] Re: TFPCHeapStatus miscalculations in 2.3.1
Seth Grover
sethdgrover at gmail.com
Tue Aug 11 15:40:38 CEST 2009
Actually I was able to distill it down into a smaller example:
------------------------------------------------
program Project1;
{$mode objfpc}{$H+}
uses
Classes, SysUtils;
function RandomRange(const low : longint;
const high : longint) : longint;
begin
if (high < low) then
result := high + random(low - high + 1)
else
Result := low + random(high - low + 1);
end;
procedure GetStats;
var
fpcHeapStatus : TFPCHeapStatus;
begin
fpcHeapStatus := GetFPCHeapStatus();
writeln(' heap status: cu=' +
IntToStr(fpcHeapStatus.CurrHeapUsed) + ', cs=' +
IntToStr(fpcHeapStatus.CurrHeapSize) + ', cf=' +
IntToStr(fpcHeapStatus.CurrHeapFree) + ', mu=' +
IntToStr(fpcHeapStatus.MaxHeapUsed) + ', ms=' +
IntToStr(fpcHeapStatus.MaxHeapSize));
end;
var
i : integer;
a : array of byte;
begin
randomize();
for i := 0 to 1000 do begin
SetLength(a, RandomRange(1024,1024*1024*15));
end;
GetStats();
SetLength(a, 0);
GetStats();
end.
------------------------------------------------
My output:
$ ./project1
heap status: cu=4277286960, cs=16154624, cf=33834960, mu=4294897312,
ms=31752192
heap status: cu=4276332896, cs=458752, cf=19093152, mu=4294897312, ms=31752192
Seems like that should never happen. I'll log an issue in the bug
tracking system.
-SG
--
This email is fiction. Any resemblance to actual events
or persons living or dead is purely coincidental.
Seth Grover
sethdgrover[at]gmail[dot]com
More information about the fpc-pascal
mailing list