Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Memory /
Chapter 2 - Memory Manager / Memory Manager Reference
Memory Manager Routines / Freeing Memory


PurgeMem

The Memory Manager purges the heap for you when you make a memory request that it can't fill. However, you can use the PurgeMem 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
The PurgeMem procedure sequentially purges blocks from the current heap zone until it either allocates a contiguous block of at least cbNeeded free bytes or has purged the entire zone. If it purges the entire zone without creating a contiguous block of at least cbNeeded free bytes, PurgeMem generates a memFullErr.

The PurgeMem procedure purges only relocatable, unlocked, purgeable blocks.

The PurgeMem procedure does not actually attempt to allocate a block of
cbNeeded bytes.

To purge the entire heap zone, call PurgeMem(maxSize).

SPECIAL CONSIDERATIONS
Because PurgeMem purges memory, you should not call it at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit for PurgeMem are
Registers on entry
D0Size of block to make room for
Registers on exit
D0Result 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 word SYS as the second argument to the routine macro, as follows:

_PurgeMem ,SYS
RESULT CODES
noErr0No error
memFullErr-108Not enough memory

Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996