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 thePurgeMem
procedure to purge the current heap zone manually.
PROCEDURE PurgeMem (cbNeeded: Size);
cbNeeded
- The size, in bytes, of the block for which
PurgeMem
should attempt to make room.DESCRIPTION
ThePurgeMem
procedure sequentially purges blocks from the current heap zone until it either allocates a contiguous block of at leastcbNeeded
free bytes or has purged the entire zone. If it purges the entire zone without creating a contiguous block of at leastcbNeeded
free bytes,PurgeMem
generates amemFullErr
.The
PurgeMem
procedure purges only relocatable, unlocked, purgeable blocks.The
PurgeMem
procedure does not actually attempt to allocate a block ofcbNeeded
bytes.To purge the entire heap zone, call
PurgeMem(maxSize)
.SPECIAL CONSIDERATIONS
BecausePurgeMem
purges memory, you should not call it at interrupt time.ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit forPurgeMem
are
Registers on entry D0 Size of block to make room for
Registers on exit D0 Result code The
PurgeMem
procedure 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 wordSYS
as the second argument to the routine macro, as follows:
_PurgeMem ,SYSRESULT CODES
noErr 0 No error memFullErr -108 Not enough memory