Carbon supports the majority of the Memory Manager programming interface. Changes primarily affect
applications that use zones, system memory, or temporary memory. For example, temporary memory allocations in Mac
OS X are allocated in the application's address space. As a result, calling TempNewHandle is effectively the
same as calling NewHandle.
Carbon does not support current functions for accessing the system heap, but Apple will provide new routines to allocate
shared and persistent memory. In addition, the virtual memory system in Mac OS X introduces a number of changes
in the addressing model.
By adhering to the following guidelines, you can increase your application's compliance with Mac OS X memory
management:
* Try to use memory only within your own application heap. Review the places where you allocate memory in the
system heap.
* Do not pass pointers to data among applications through Apple events, Gestalt routines, or other means. For example,
don't share Toolbox data structures between applications, because in Mac OS X, each application runs in its own
protected address space.
* Do not use inline, hard-coded addresses.
* Do not modify the zone header to increase the number of master pointer blocks
allocated by each call to the MoreMasters function. You should instead call
MoreMasters multiple times. Each call to More Masters allocates 128 master pointers.
Apple may supply a new version of the MoreMasters function that allows you to
specify the number of master pointer blocks to allocate. Note, however, that
master pointer blocks do not need to be preallocated or optimized in the Mac
OS X environment, so the new function will only benefit Carbon applications
running on Mac OS 8 and 9.
* Don't make assumptions about the layout of memory, such as the relative position of data stored in heaps, stacks, and
other memory areas.
* Don't use the DisposePtr or DisposeHandle functions on pointers or handles allocated by Toolbox managers. For
example, don't call the function DisposeHandle on a control allocated by the NewControl function; use DisposeControl
instead.
* Because Mac OS X applications run in their own large, protected memory spaces, memory sizing routines such as
MaxMem and FreeMem will work differently than they do now.