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 / Assessing Memory Conditions


FreeMem

By calling the FreeMem function, you can find out the total amount of free space, in bytes, in the current heap zone.

FUNCTION FreeMem: LongInt;
DESCRIPTION
The FreeMem function returns the total amount of free space (in bytes) in the current heap zone. Note that it usually isn't possible to allocate a block of that size, because
of heap fragmentation due to nonrelocatable or locked blocks.

SPECIAL CONSIDERATIONS
Even though FreeMem does not move or purge memory, you should not call it at interrupt time because the heap might be in an inconsistent state.

ASSEMBLY-LANGUAGE INFORMATION
The registers on exit for FreeMem are
Registers on exit
D0Number of bytes available in heap zone

The FreeMem function reports the number of free bytes in the current heap zone. If you want to know how many bytes are available in the system heap zone rather than in 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:

_FreeMem ,SYS
RESULT CODES
noErr 0No error

Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996