CBFalconer wrote:
Russell Whitaker wrote:
Got the following from "Borland Pascal with Objects - Language Guide"
function MaxAvail "Returns the size of the largest contiguous free block in the heap, indicating the size of the largest dynamic varible that can be allocated at the time of the call to MaxAvail."
function MemAvail "Returns the number of free bytes of heap storage available."
Also on another page there is a blurb on how to make New and GetMem return nil instead of aborting the program.
These are typical Borland kludges, that don't and can't port to modern systems with virtual memory.
I'd like to second this. Even if MaxAvail returns a size greater than what you want to allocate, a subsequent allocation is not guaranteed to succeed. (Note, even in the BP description, "at the time", not shortly afterwards ...)
These functions just do not make much sense on multitasking systems. ISTR even the FPC people, who are very close to Borland otherwise, discourage their use.
Checking an allocation aftwards is a better thing to do. Unfortunately, GPC doesn't yet offer the best possible capabilities to do that ...
Frank