GetFPCHeapStatus reports incorrect information after lots of allocation/reallocation
Original Reporter info from Mantis: sethdgrover@gmail.com
-
Reporter name: Seth Grover
Original Reporter info from Mantis: sethdgrover@gmail.com
- Reporter name: Seth Grover
Description:
Using the program provided below, which just does a lot of allocation and reallocation by changing an array size, the stats reported by GetFPCHeapStatus are incorrect.
CurrHeapFree is greater than CurrHeapSize, so CurrHeapUsed and MaxHeapUsed overflow and are interpreted as being very large.
My output from the program:
$ ./project1
heap status: cu=4275979072,cs=16154624,cf=35142848,mu=4294944112,ms=31817728
heap status: cu=4273235456,cs=458752,cf=22190592,mu=4294944112,ms=31817728
Additional information:
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.
Mantis conversion info:
- Mantis ID: 14315
- OS: Linux (2.6.28-14-generic)
- OS Build: Ubuntu 9.04
- Build: svn revision 13497
- Platform: x86
- Version: 2.3.1
- Fixed in version: 2.6.1
- Fixed in revision: 22640 (#73a837e8)
- Monitored by: » sethdgrover@gmail.com (Seth Grover)