previous next top contents index framed top this page unframed
Figure 41–8. $memoryManagementInfo
| PROCEDURE $memoryManagementInfo (INTEGER info); |
$memoryManagementInfo allows a program to tell the MAINSAIL runtime system that little or no garbage is being generated during a certain phase of execution. This is useful if a lot of memory is being allocated, but none of the allocated memory will contain garbage. Allocation of a large amount of memory would normally trigger garbage collections, but if no garbage is being generated, the collections would serve no purpose. Calling $memoryManagementInfo reduces the likelihood that such unprofitable garbage collections will occur, although it does not completely prevent collections, as would incrementing $collectLock. Also, $memoryManagementInfo may be specified for either chunk (i.e., dynamic object) or STRING garbage; $collectLock locks out both kinds of garbage collection.
The parameter info takes one of the following four values, with the meanings shown:
| Value | Meaning |
|---|---|
| $noNewChunkGarbage | dynamic objects being allocated will not be garbage |
| - $noNewChunkGarbage | undoes $noNewChunkGarbage |
| $noNewStringGarbage | STRINGs being allocated will not be garbage |
| - $noNewStringGarbage | undoes $noNewStringGarbage |
$memoryManagementInfo actually increments or decrements a counter, so calling it with the value - $noNewChunkGarbage or - $noNewStringGarbage does not guarantee that normal assumptions about garbage will resume; to ensure this, $memoryManagementInfo(- $noNewChunkGarbage) must be called exactly as many times as was $memoryManagement($noNewChunkGarbage); the same is true of $noNewStringGarbage. To ensure that an exception that occurs during a time when $memoryManagement($noNewChunkGarbage) is in effect does not abort the code where $memoryManagementInfo(- $noNewChunkGarbage) is done, it is recommended that a $HANDLE statement be used that calls $memoryManagementInfo(- $noNewChunkGarbage) when $abortProcedureExcpt is raised.
MAINSAIL Language Manual, Section 41.9