[fpc-pascal] Memory Size

Markus Glugla fpc at xgelb.de
Fri Apr 3 02:34:11 CEST 2009


Hi,

I need the available memory (heap). At that time the functions maxavail
or memavail did this. I read that I should use GetFPCHeapStatus and
other function currently.

This functions produce allways zero!! What can I do? What is wrong?
I use fpc version 2.2.0 [2008/05/27] for i386.


Here is some source and output to describe the problem:

program memory;
var
  a:TFPCHeapStatus;
  b:THeapStatus;
begin
  a:=GetFPCHeapStatus;
  writeln(a.MaxHeapSize);
  writeln(a.MaxHeapUsed);
  writeln(a.CurrHeapSize);
  writeln(a.CurrHeapUsed);
  writeln(a.CurrHeapFree);

  writeln('-----');

  b:=GetHeapStatus;
  writeln(b.TotalAddrSpace);
  writeln(b.TotalUncommitted);
  writeln(b.TotalCommitted);
  writeln(b.TotalAllocated);
  writeln(b.TotalFree);
  writeln(b.FreeSmall);
  writeln(b.FreeBig);
  writeln(b.Unused);
  writeln(b.Overhead);
  writeln(b.HeapErrorCode);

  writeln('#################-----');

  a:=SysGetFPCHeapStatus;
  writeln(a.MaxHeapSize);
  writeln(a.MaxHeapUsed);
  writeln(a.CurrHeapSize);
  writeln(a.CurrHeapUsed);
  writeln(a.CurrHeapFree);

  writeln('-----');

  b:=SysGetHeapStatus;
  writeln(b.TotalAddrSpace);
  writeln(b.TotalUncommitted);
  writeln(b.TotalCommitted);
  writeln(b.TotalAllocated);
  writeln(b.TotalFree);
  writeln(b.FreeSmall);
  writeln(b.FreeBig);
  writeln(b.Unused);
  writeln(b.Overhead);
  writeln(b.HeapErrorCode);
end.


This source generate the following output:

0
0
0
0
0
-----
0
0
0
0
0
0
0
0
0
0
#################-----
0
0
0
0
0
-----
0
0
0
0
0
0
0
0
0
0
 






More information about the fpc-pascal mailing list