MaxAvail
Jump to navigation
Jump to search
Returns the size of the largest contiguous free block in the heap.
- Declaration
function MaxAvail: Longint;
- Target
- Windows, Real, Protected
- Remarks
- Returns the larger of:
- the largest free blocks within the heap manager's sub-allocation space
- the Windows global heap
- The value corresponds to the size of the largest dynamic variable that can be allocated at that time.
- See Also
- MemAvail
Sample Code
{FreeMem.PAS} {Sample code for the FreeMem and GetMem procedures and the MaxAvail function.} { For Windows: } { uses WinCrt; } type TFriendRec = record Name: string[30]; Age : Byte; end; var p: pointer; begin if MaxAvail < SizeOf(TFriendRec) then Writeln('Not enough memory') else begin { Allocate memory on heap } GetMem(p, SizeOf(TFriendRec)); { ...} { ...Use the memory... } { ...} { Then free it when done } FreeMem(p, SizeOf(TFriendRec)); end; end.