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 / Setting Up the Application Heap


MoreMasters

Call the MoreMasters procedure several times at the beginning of your program to prevent the Memory Manager from running out of master pointers in the middle of application execution. If it does run out, it allocates more, possibly causing heap fragmentation.

PROCEDURE MoreMasters;
DESCRIPTION
The MoreMasters procedure allocates another block of master pointers in the current heap zone. In the application heap, a block of master pointers consists of 64 master pointers, and in the system heap, a block consists of 32 master pointers. (These values, however, might change in future versions of system software.) When you initialize additional heap zones, you can specify the number of master pointers you want to have in a block of master pointers.

The Memory Manager automatically calls MoreMasters once for every new heap zone, including the application heap zone.

You should call MoreMasters at the beginning of your program enough times to ensure that the Memory Manager never needs to call it for you. For example, if your application never allocates more than 300 relocatable blocks in its heap zone, then five calls to the MoreMasters should be enough. It's better to call MoreMasters too many times than too few. For instance, if your application usually allocates about 100 relocatable blocks but might allocate 1000 in a particularly busy session, call MoreMasters enough times at the beginning of the program to accommodate times of greater memory use.

If you are forced to call MoreMasters so many times that it causes a significant slowdown, you could change the moreMast field of the zone header to the total number of master pointers you need and then call MoreMasters just once. Afterward, be sure to restore the moreMast field to its original value.

SPECIAL CONSIDERATIONS
Because MoreMasters allocates memory, you should not call it at interrupt time.

The calls to MoreMasters at the beginning of your application should be in the main code segment of your application or in a segment that the main segment never unloads.

ASSEMBLY-LANGUAGE INFORMATION
The registers on exit for MoreMasters are
Registers on exit
D0Result code

RESULT CODES
noErr0No error
memFullErr-108Not enough memory
SEE ALSO
If you initialize a new zone, you can specify the number of master pointers that a master pointer block should contain. See the description of the InitZone procedure on page 2-86 for details.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996