8.4.2 The heap grows

The heap allocates memory from the operating system on an as-needed basis.

OS memory is requested in blocks: It first tries to increase memory in a 64Kb chunk if the size to allocate is less than 64Kb, or 256Kb or 1024K otherwise. If this fails, it tries to increase the heap by the amount you requested from the heap.

If the attempt to reserve OS memory fails, the value returned depends on the value of the ReturnNilIfGrowHeapFails global variable. This is summarized in table (8.9).


Table 8.9: ReturnNilIfGrowHeapFails value



ReturnNilGrowHeapFailsDefault memory
value manager action


FALSE (The default) Runtime error 203 generated
TRUE GetMem, ReallocMem and New returns nil



ReturnNilIfGrowHeapFails can be set to change the behavior of the default memory manager error handler.