Name

THeapStatus Type

Syntax

type
  THeapStatus = record
    TotalAddrSpace: Cardinal;
    TotalUncommitted: Cardinal;
    TotalCommitted: Cardinal;
    TotalAllocated: Cardinal;
    TotalFree: Cardinal;
    FreeSmall: Cardinal;
    FreeBig: Cardinal;
    Unused: Cardinal;
    Overhead: Cardinal;
    HeapErrorCode: Cardinal;
  end;

Description

The GetHeapStatus function returns a THeapStatus record. This record provides information about Delphi’s internal memory manager. If you install a custom memory manager, all of the heap status values, which are shown in the following list, will probably be zero.

TotalAddrSpace

The total number of bytes being managed by the memory manager. Delphi starts out with 1MB of virtual memory. The address space grows as needed:

TotalAddrSpace = TotalUncommitted + TotalCommitted.

TotalUncommitted

The total number of bytes being managed that have not been allocated space in the swap file.

TotalCommitted

The total number of bytes being managed that have been allocated space in the swap file:

TotalCommitted = TotalAllocated + TotalFree + Overhead.

TotalAllocated

The total number of bytes currently allocated and being used by your program.

TotalFree

The total number of bytes free to be allocated by your program. When the available free memory is too small to fulfill an allocation request, the memory manager gets additional memory from Windows.

TotalFree = FreeSmall + FreeBig + Unused.

FreeSmall

The total number of bytes in the lists of free small blocks. The memory manager keeps lists of free blocks at certain “small” sizes. Each list holds blocks of a single size. Most memory requests in an average program are for small blocks, so the manager can fulfill these requests quickly by returning the address of a small block from the appropriate list. “Small” is under 4KB.

FreeBig

For blocks larger than 4KB, Delphi keeps a single list of large blocks. Large memory requests come from the list of big blocks. The first block big enough to meet a request is carved into two pieces: the part that is allocated and returned, and the remainder, which goes back into the free list.

Unused

The number of bytes that are under control of the memory manager but have not yet been allocated by your program.

Overhead

The number of bytes of overhead imposed by the memory manager to keep track of its allocated blocks.

HeapErrorCode

An internal error code, which should be zero. A non-zero value means the memory manager’s internal data structures are damaged. The program’s behavior will be unpredictable, but you should expect an access violation or similar error. If you want to know about the specific error codes, and you have the Professional or better version of Delphi, see SourceRtlGetMem.inc.

See Also

GetHeapStatus Function, IsMemoryManagerSet Function, SetMemoryManager Procedure
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset