Important: The information in this document is obsolete and should not be used for new development.
PurgeMem
The Memory Manager purges the heap for you when you make a memory request that it can't fill. However, you can use thePurgeMemprocedure to purge the current heap zone manually.
PROCEDURE PurgeMem (cbNeeded: Size);
cbNeeded- The size, in bytes, of the block for which
PurgeMemshould attempt to make room.DESCRIPTION
ThePurgeMemprocedure sequentially purges blocks from the current heap zone until it either allocates a contiguous block of at leastcbNeededfree bytes or has purged the entire zone. If it purges the entire zone without creating a contiguous block of at leastcbNeededfree bytes,PurgeMemgenerates amemFullErr.The
PurgeMemprocedure purges only relocatable, unlocked, purgeable blocks.The
PurgeMemprocedure does not actually attempt to allocate a block ofcbNeededbytes.To purge the entire heap zone, call
PurgeMem(maxSize).SPECIAL CONSIDERATIONS
BecausePurgeMempurges memory, you should not call it at interrupt time.ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit forPurgeMemare
Registers on entry D0 Size of block to make room for
Registers on exit D0 Result code The
PurgeMemprocedure purges the current heap zone. If you want to purge the system heap zone rather than the current heap zone, set bit 10 of the routine trap word. In most development systems, you can do this by supplying the wordSYSas the second argument to the routine macro, as follows:
_PurgeMem ,SYSRESULT CODES
noErr 0 No error memFullErr -108 Not enough memory