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


MemError

To find out whether your application's last direct call to a Memory Manager routine executed successfully, use the MemError function.

FUNCTION MemError: OSErr;
DESCRIPTION
The MemError function returns the result code produced by the last Memory Manager routine your application called directly.

This function is useful during application debugging. You might also use the function as one part of a memory-management scheme to identify instances in which the Memory Manager rejects overly large memory requests by returning the error code memFullErr.

WARNING
Do not rely on the MemError function as the only component of a memory-management scheme. For example, suppose you call NewHandle or NewPtr and receive the result code noErr, indicating that the Memory Manager was able to allocate sufficient memory. In this case, you have no guarantee that the allocation did not deplete your application's memory reserves to levels so low that simple operations might cause your application to crash. Instead of relying on MemError, check before making a memory request that there is enough memory both to fulfill the request and to support essential operations.
ASSEMBLY-LANGUAGE INFORMATION
Because most Memory Manager routines return a result code in register D0, you do not ordinarily need to call the MemError function if you program in assembly language. See the description of an individual routine to find out whether it returns a result code in register D0. If not, you can examine the global variable MemErr. When MemError returns, register D0 contains the result code.
Registers on exit
D0Result code

RESULT CODES
noErr0No error
paramErr-50Error in parameter list
memROZErr-99Operation on a read-only zone
memFullErr-108Not enough memory
nilHandleErr-109NIL master pointer
memWZErr-111Attempt to operate on a free block
memPurErr-112Attempt to purge a locked block
memBCErr-115Block check failed
memLockedErr-117Block is locked

Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996