< Previous PageNext Page > Hide TOC

Deprecated Memory Manager Functions

A function identified as deprecated has been superseded and may become unsupported in the future.

Deprecated in Mac OS X v10.4

CheckAllHeaps

Checks all known heaps for validity. (Deprecated in Mac OS X v10.4. There is no replacement function; an application has access only to its own heap in Mac OS X.)

Boolean CheckAllHeaps (
   void
);

Availability
Declared In
MacMemory.h

CompactMem

Compacts the heap by moving relocatable blocks as needed. (Deprecated in Mac OS X v10.4. There is no replacement function; memory compaction is never needed and never performed in Mac OS X.)

Size CompactMem (
   Size cbNeeded
);

Parameters
cbNeeded

The size, in bytes, of the block for which CompactMem should attempt to make room.

Return Value

The size, in bytes, of the largest contiguous free block available after compacting the heap zone. CompactMem does not actually allocate that block.

Discussion

The Memory Manager automatically compacts the heap when a memory request fails. However, you can use the CompactMem function to compact the current heap zone manually.

CompactMem compacts the current heap zone not by purging blocks, but rather by moving unlocked, relocatable blocks down until they encounter nonrelocatable blocks or locked, relocatable blocks. CompactMem continues compacting until it either finds a contiguous block of at least cbNeeded free bytes or compacts the entire zone.

To compact the entire heap zone, call CompactMem(maxSize).

Call the function MemError to get the result code. See “Memory Manager Result Codes.”

Because CompactMem moves memory, you should not call it at interrupt time.

Availability
Declared In
MacMemory.h

DisposeGrowZoneUPP

(Deprecated in Mac OS X v10.4. There is no replacement function; heaps never grow in Mac OS X, so the grow-zone function is never called.)

void DisposeGrowZoneUPP (
   GrowZoneUPP userUPP
);

Parameters
userUPP
Availability
Declared In
MacMemory.h

DisposePurgeUPP

(Deprecated in Mac OS X v10.4. There is no replacement function; heaps are never purged in Mac OS X, so the purge function is never called.)

void DisposePurgeUPP (
   PurgeUPP userUPP
);

Parameters
userUPP
Availability
Declared In
MacMemory.h

DisposeUserFnUPP

(Deprecated in Mac OS X v10.4. There is no replacement; this function was included to facilitate porting legacy applications to Carbon, but it serves no useful purpose in Mac OS X.)

void DisposeUserFnUPP (
   UserFnUPP userUPP
);

Parameters
userUPP
Availability
Declared In
MacMemory.h

FlushMemory

Makes a portion of the address space clean. (Deprecated in Mac OS X v10.4. There is no replacement; this function does nothing in Mac OS X.)

OSErr FlushMemory (
   void *address,
   unsigned long count
);

Return Value

This function always returns a value of noErr.

Availability
Declared In
MacMemory.h

GetGrowZone

Returns the current heap zone’s grow-zone function. (Deprecated in Mac OS X v10.4. There is no replacement function; heaps never grow in Mac OS X, so the grow-zone function is never used.)

GrowZoneUPP GetGrowZone (
   void
);

Return Value

See the description of the GrowZoneUPP data type.

Availability
Declared In
MacMemory.h

GZSaveHnd

Returns a relocatable block to be protected during grow-zone operations. (Deprecated in Mac OS X v10.4. There is no replacement; this function does nothing in Mac OS X.)

Handle GZSaveHnd (
   void
);

Return Value

A handle to a block of memory that the Memory Manager reserves during grow-zone operations. Your grow-zone function must not move, purge, or delete this block. This function returns NULL if there is no such block.

Availability
Declared In
MacMemory.h

HNoPurge

Marks a relocatable block as unpurgeable. (Deprecated in Mac OS X v10.4. There is no replacement function; heaps are never purged in Mac OS X.)

void HNoPurge (
   Handle h
);

Parameters
h

A handle to a relocatable block.

Discussion

The HNoPurge function marks the relocatable block, to which h is a handle, as unpurgeable. If the block is already unpurgeable, HNoPurge does nothing.

The HNoPurge function does not reallocate memory for a handle if it has already been purged.

If you want to reallocate memory for a relocatable block that has already been purged, you can use the ReallocateHandle function.

Call the function MemError to get the result code. See “Memory Manager Result Codes.”

Availability
Declared In
MacMemory.h

HoldMemory

Makes a portion of the address space resident in physical memory and ineligible for paging. (Deprecated in Mac OS X v10.4. There is no replacement; this function does nothing in Mac OS X.)

OSErr HoldMemory (
   void *address,
   unsigned long count
);

Parameters
address

A pointer indicating the starting address of the range of memory to be held in RAM.

count

The size, in bytes, of the range of memory to be held in RAM.

Return Value

This function always returns a value of noErr.

Discussion

If the starting address you supply to the HoldMemory function is not on a page boundary, then HoldMemory rounds down to the nearest page boundary. Similarly, if the specified range does not end on a page boundary, HoldMemory rounds up the value you pass in the count parameter so that the entire range of memory is held.

Even though HoldMemory does not move or purge memory, you should not call it at interrupt time.

Availability
Declared In
MacMemory.h

HPurge

Marks a relocatable block as purgeable. (Deprecated in Mac OS X v10.4. There is no replacement function; heaps are never purged in Mac OS X.)

void HPurge (
   Handle h
);

Parameters
h

A handle to a relocatable block.

Discussion

The HPurge function marks the relocatable block, to which h is a handle, as purgeable. If the block is already purgeable, HPurge does nothing.

The Memory Manager might purge the block when it needs to purge the heap zone containing the block to satisfy a memory request. A direct call to the MaxMem function would also purge blocks marked as purgeable.

Once you mark a relocatable block as purgeable, you should make sure that handles to the block are not empty before you access the block. If they are empty, you must reallocate space for the block and recopy the block’s data from another source, such as a resource file, before using the information in the block.

If the block to which h is a handle is locked, HPurge does not unlock the block but does mark it as purgeable. If you later call HUnlock on h, the block is subject to purging.

If the Memory Manager has purged a block, you can reallocate space for it by using the ReallocateHandle function.

You can immediately free the space taken by a handle without disposing of it by calling the function EmptyHandle. This function does not require that the block be purgeable.

Call the function MemError to get the result code. See “Memory Manager Result Codes.”

Availability
Declared In
MacMemory.h

InvokeGrowZoneUPP

(Deprecated in Mac OS X v10.4. There is no replacement function; heaps never grow in Mac OS X, so the grow-zone function is never called.)

long InvokeGrowZoneUPP (
   Size cbNeeded,
   GrowZoneUPP userUPP
);

Parameters
cbNeeded
userUPP
Availability
Declared In
MacMemory.h

InvokePurgeUPP

(Deprecated in Mac OS X v10.4. There is no replacement function; heaps are never purged in Mac OS X, so the purge function is never called.)

void InvokePurgeUPP (
   Handle blockToPurge,
   PurgeUPP userUPP
);

Parameters
blockToPurge
userUPP
Availability
Declared In
MacMemory.h

InvokeUserFnUPP

(Deprecated in Mac OS X v10.4. There is no replacement; this function was included to facilitate porting legacy applications to Carbon, but it serves no useful purpose in Mac OS X.)

void InvokeUserFnUPP (
   void *parameter,
   UserFnUPP userUPP
);

Parameters
parameter
userUPP
Availability
Declared In
MacMemory.h

LMGetApplZone

(Deprecated in Mac OS X v10.4. There is no replacement; this function was included to facilitate porting legacy applications to Carbon, but it serves no useful purpose in Mac OS X.)

THz LMGetApplZone (
   void
);

Availability
Declared In
MacMemory.h

LMGetSysZone

(Deprecated in Mac OS X v10.4. There is no replacement; this function was included to facilitate porting legacy applications to Carbon, but it serves no useful purpose in Mac OS X.)

THz LMGetSysZone (
   void
);

Availability
Declared In
MacMemory.h

LMSetApplZone

(Deprecated in Mac OS X v10.4. There is no replacement; this function was included to facilitate porting legacy applications to Carbon, but it serves no useful purpose in Mac OS X.)

void LMSetApplZone (
   THz value
);

Availability
Declared In
MacMemory.h

LMSetSysZone

(Deprecated in Mac OS X v10.4. There is no replacement; this function was included to facilitate porting legacy applications to Carbon, but it serves no useful purpose in Mac OS X.)

void LMSetSysZone (
   THz value
);

Availability
Declared In
MacMemory.h

MakeMemoryNonResident

Makes pages in the specified range immediately available for reuse. (Deprecated in Mac OS X v10.4. There is no replacement; this function does nothing in Mac OS X.)

OSErr MakeMemoryNonResident (
   void *address,
   unsigned long count
);

Return Value

This function always returns a value of noErr.

Availability
Declared In
MacMemory.h

MakeMemoryResident

Makes a portion of the address space resident in physical memory. (Deprecated in Mac OS X v10.4. There is no replacement; this function does nothing in Mac OS X.)

OSErr MakeMemoryResident (
   void *address,
   unsigned long count
);

Return Value

A result code. See “Memory Manager Result Codes.”

Availability
Declared In
MacMemory.h

MoreMasterPointers

Allocates a specified number of master pointers in the current heap zone. (Deprecated in Mac OS X v10.4. There is no replacement function; master pointers do not need to be pre-allocated in Mac OS X.)

void MoreMasterPointers (
   UInt32 inCount
);

Parameters
inCount

The number of master pointers you want to allocate in a single nonrelocatable block.

Carbon Porting Notes

Carbon applications should use this function instead of MoreMasters to allocate a nonrelocatable block of master pointers in the current heap zone.

Availability
Declared In
MacMemory.h

MoreMasters

Allocates a block of master pointers in the current heap zone. (Deprecated in Mac OS X v10.4. There is no replacement function; master pointers do not need to be pre-allocated in Mac OS X.)

void MoreMasters (
   void
);

Discussion

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 are likely to increase 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 the MoreMasters function once for every new heap zone, including the application heap zone.

Call MoreMasters 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.

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 to accommodate the largest amount.

If you initialize a new zone, you can specify the number of master pointers that a master pointer block should contain.

Call the MemError function to get the result code. See “Memory Manager Result Codes.”

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.

Carbon Porting Notes

You should instead use MoreMasterPointers.

Availability
Related Sample Code
Declared In
MacMemory.h

MoveHHi

Moves a relocatable block as high in memory as possible. (Deprecated in Mac OS X v10.4. There is no replacement function; there is no benefit to moving handles high in memory in Mac OS X.)

void MoveHHi (
   Handle h
);

Parameters
h

A handle to a relocatable block.

Discussion

This function moves a relocatable block as high in memory as possible to help prevent heap fragmentation. The MoveHHi function attempts to move the relocatable block referenced by the handle h upward until it reaches a nonrelocatable block, a locked relocatable block, or the top of the heap.

If you plan to lock a relocatable block for a short period of time, use the MoveHHi function, which moves the block to the top of the heap and thus helps prevent heap fragmentation.

If you call MoveHHi to move a handle to a resource that has its resChanged bit set, the Resource Manager updates the resource by using the WriteResource function to write the contents of the block to disk. If you want to avoid this behavior, call the Resource Manager function SetResPurge(FALSE) before you call MoveHHi, and then call SetResPurge(TRUE) to restore the default setting.

By using the MoveHHi function on relocatable blocks you plan to allocate for short periods of time, you help prevent islands of immovable memory from accumulating in (and thus fragmenting) the heap.

Do not use the MoveHHi function to move blocks you plan to lock for long periods of time. The MoveHHi function moves such blocks to the top of the heap, perhaps preventing other blocks already at the top of the heap from moving down once they are unlocked. Instead, use the ReserveMem function before allocating such blocks, thus keeping them in the bottom partition of the heap, where they do not prevent relocatable blocks from moving.

If you frequently lock a block for short periods of time and find that calling MoveHHi each time slows down your application, you might consider leaving the block always locked and calling the ReserveMem function before allocating it.

Once you move a block to the top of the heap, be sure to lock it if you do not want the Memory Manager to move it back to the middle partition as soon as it can. (The MoveHHi function cannot move locked blocks; be sure to lock blocks after, not before, calling MoveHHi.)

Using the MoveHHi function without taking other precautionary measures to prevent heap fragmentation is useless, because even one small nonrelocatable or locked relocatable block in the middle of the heap might prevent MoveHHi from moving blocks to the top of the heap.

Call the function MemError to get the result code. See “Memory Manager Result Codes.”

Availability
Declared In
MacMemory.h

NewGrowZoneUPP

(Deprecated in Mac OS X v10.4. There is no replacement function; heaps never grow in Mac OS X, so the grow-zone function is never called.)

GrowZoneUPP NewGrowZoneUPP (
   GrowZoneProcPtr userRoutine
);

Parameters
userRoutine
Return Value

See the description of the GrowZoneUPP data type.

Availability
Declared In
MacMemory.h

NewPurgeUPP

(Deprecated in Mac OS X v10.4. There is no replacement function; heaps are never purged in Mac OS X, so the purge function is never called.)

PurgeUPP NewPurgeUPP (
   PurgeProcPtr userRoutine
);

Parameters
userRoutine
Return Value

See the description of the PurgeUPP data type.

Availability
Declared In
MacMemory.h

NewUserFnUPP

(Deprecated in Mac OS X v10.4. There is no replacement; this function was included to facilitate porting legacy applications to Carbon, but it serves no useful purpose in Mac OS X.)

UserFnUPP NewUserFnUPP (
   UserFnProcPtr userRoutine
);

Parameters
userRoutine
Return Value

See the description of the UserFnUPP data type.

Availability
Declared In
MacMemory.h

PurgeMem

Purges the current heap zone until the specified number of bytes are available. (Deprecated in Mac OS X v10.4. There is no replacement; heaps are never purged in Mac OS X, so this function does nothing.)

void PurgeMem (
   Size cbNeeded
);

Parameters
cbNeeded

The size, in bytes, of the block for which PurgeMem should attempt to make room.

Discussion

The Memory Manager purges the heap automatically when a memory request fails. However, you can use PurgeMem to purge the current heap zone manually.

The PurgeMem function sequentially purges blocks from the current heap zone until it either allocates a contiguous block of the specified size or purges the entire zone. If PurgeMem purges the entire zone without creating a contiguous block of the specified size, PurgeMem generates the result code memFullErr.

Call the function MemError to get the result code. See “Memory Manager Result Codes.”

The PurgeMem function purges only relocatable, unlocked, purgeable blocks. The function does not actually attempt to allocate the memory.

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

Availability
Declared In
MacMemory.h

PurgeSpace

Determines the total amount of free memory and the size of the largest allocatable block in the current heap zone if it were purged. (Deprecated in Mac OS X v10.4. There is no replacement; heaps are never purged in Mac OS X.)

void PurgeSpace (
   long *total,
   long *contig
);

Parameters
total

On return, the total amount of free memory, in bytes, in the current heap zone if it were purged. This amount includes space that is already free.

contig

On return, the size of the largest contiguous block of free memory in the current heap zone if it were purged.

Discussion

The PurgeSpace function does not actually purge the current heap zone.

Call the function MemError to get the result code. See “Memory Manager Result Codes.”

Availability
Declared In
MacMemory.h

PurgeSpaceContiguous

(Deprecated in Mac OS X v10.4. There is no replacement; heaps are never purged in Mac OS X.)

long PurgeSpaceContiguous (
   void
);

Availability
Declared In
MacMemory.h

PurgeSpaceTotal

(Deprecated in Mac OS X v10.4. There is no replacement; heaps are never purged in Mac OS X.)

long PurgeSpaceTotal (
   void
);

Availability
Declared In
MacMemory.h

ReleaseMemoryData

Releases the data of a portion of the address space. (Deprecated in Mac OS X v10.4. There is no replacement; this function does nothing in Mac OS X.)

OSErr ReleaseMemoryData (
   void *address,
   unsigned long count
);

Return Value

This function always returns a value of noErr.

Availability
Declared In
MacMemory.h

ReserveMem

Reserves space for a block of memory as close to the bottom of the current heap zone as possible. (Deprecated in Mac OS X v10.4. There is no replacement; this function does nothing in Mac OS X.)

void ReserveMem (
   Size cbNeeded
);

Parameters
cbNeeded

The number of bytes to reserve near the bottom of the heap.

Discussion

The ReserveMem function attempts to create free space for the specified number of contiguous logical bytes at the lowest possible position in the current heap zone. It pursues every available means of placing the block as close as possible to the bottom of the zone, including moving other relocatable blocks upward, expanding the zone (if possible), and purging blocks from it.

Use the ReserveMem function when allocating a relocatable block that you intend to lock for long periods of time. This helps prevent heap fragmentation because it reserves space for the block as close to the bottom of the heap as possible. Consistent use of ReserveMem for this purpose ensures that all locked, relocatable blocks and nonrelocatable blocks are together at the bottom of the heap zone and thus do not prevent unlocked relocatable blocks from moving about the zone.

Because ReserveMem does not actually allocate the block, you must combine calls to ReserveMem with calls to the NewHandle function.

Do not use the ReserveMem function for a relocatable block you intend to lock for only a short period of time. If you do so and then allocate a nonrelocatable block above it, the relocatable block becomes trapped under the nonrelocatable block when you unlock that relocatable block.

It isn’t necessary to call ReserveMem to reserve space for a nonrelocatable block, because the NewPtr function calls it automatically.

Also, you do not need to call ReserveMem to reserve memory before you load a locked resource into memory, because the Resource Manager calls ReserveMem automatically.

Call the function MemError to get the result code. See “Memory Manager Result Codes.”

Because the ReserveMem function could move and purge memory, you should not call it at interrupt time.

Availability
Declared In
MacMemory.h

SetGrowZone

Specifies the current heap zone’s grow-zone function. (Deprecated in Mac OS X v10.4. There is no replacement function; heaps never grow in Mac OS X, so the grow-zone function is never called.)

void SetGrowZone (
   GrowZoneUPP growZone
);

Parameters
growZone

A pointer to the grow-zone function. A NULL value removes any previous grow-zone function from the zone.

Discussion

To specify a grow-zone function for the current heap zone, pass a pointer to that function to the SetGrowZone function. Usually you call this function early in the execution of your application.

If you initialize your own heap zones besides the application and system zones, you can alternatively specify a grow-zone function as a parameter to the InitZone function.

The Memory Manager calls the grow-zone function only after exhausting all other avenues of satisfying a memory request, including compacting the zone, increasing its size (if it is the original application zone and is not yet at its maximum size), and purging blocks from it.

See “Grow-Zone Operations” for a complete description of a grow-zone function.

Availability
Declared In
MacMemory.h

TempFreeMem

Returns the maximum amount of free memory in the temporary heap. (Deprecated in Mac OS X v10.4. There is no replacement function; Mac OS X does not have a separate temporary memory heap.)

long TempFreeMem (
   void
);

Return Value

The total amount of free temporary memory, in bytes, that you could allocate by calling TempNewHandle. Because these bytes might be dispersed throughout memory, it is ordinarily not possible to allocate a single relocatable block of that size.

Discussion

Returns the total amount of memory available for temporary allocation.

Special Considerations

In Mac OS X, there is no separate temporary memory heap. This function always returns a large value, because virtual memory is always available to fulfill any request for memory. You can assume that any reasonable memory allocation request will succeed.

Availability
Declared In
MacMemory.h

TempHLock

Locks a relocatable block in the temporary heap. (Deprecated in Mac OS X v10.4. Use HLock instead; Mac OS X does not have a separate temporary memory heap.)

void TempHLock (
   Handle h,
   OSErr *resultCode
);

Availability
Declared In
MacMemory.h

TempHUnlock

Unlocks a relocatable block in the temporary heap. (Deprecated in Mac OS X v10.4. Use HUnlock instead; Mac OS X does not have a separate temporary memory heap.)

void TempHUnlock (
   Handle h,
   OSErr *resultCode
);

Availability
Declared In
MacMemory.h

TempMaxMem

Returns the maximum amount of temporary memory available. (Deprecated in Mac OS X v10.4. There is no replacement function; Mac OS X does not have a separate temporary memory heap.)

Size TempMaxMem (
   Size *grow
);

Parameters
grow

On return, this parameter always contains 0 after the function call because temporary memory does not come from the application’s heap zone, and only that zone can grow. Ignore this parameter.

Return Value

The size of the largest contiguous block available for temporary allocation.

Discussion

Compacts the current heap zone and returns the size of the largest contiguous block available for temporary allocation.

Special Considerations

In Mac OS X, there is no separate temporary memory heap. This function always returns a large value, because virtual memory is always available to fulfill any request for memory. You can assume that any reasonable memory allocation request will succeed.

Availability
Declared In
MacMemory.h

TempTopMem

Returns the location of the top of the temporary heap. (Deprecated in Mac OS X v10.4. There is no replacement function; Mac OS X does not have a separate temporary memory heap.)

Ptr TempTopMem (
   void
);

Discussion

In Mac OS X, this function always returns NULL.

Availability
Declared In
MacMemory.h

TopMem

Returns a pointer to the byte at the top of an application’s partition. (Deprecated in Mac OS X v10.4. There is no replacement; this function does nothing in Mac OS X.)

Ptr TopMem (
   void
);

Discussion

Deprecated. Refer to MacMemory.h for information on replacement functions.

TopMem obtains a pointer to the byte at the top of an application’s partition, directly above the jump table. TopMem does this to maintain compatibility with programs that check TopMem to find out how much memory is installed in a computer. The preferred method of obtaining this information is with the Gestalt function.

The function exhibits special behavior at startup time, and the value it returns controls the amount by which an extension can lower the value of the global variable BufPtr at startup time. If you are writing a system extension, you should not lower the value of BufPtr by more than MemTop DIV 2 + 1024. If you do lower BufPtr too far, the startup process generates an out-of-memory system error.

You should never need to call TopMem except during the startup process.

Availability
Declared In
MacMemory.h

UnholdMemory

Makes a currently held range of memory eligible for paging again. (Deprecated in Mac OS X v10.4. There is no replacement; this function does nothing in Mac OS X.)

OSErr UnholdMemory (
   void *address,
   unsigned long count
);

Parameters
address

A pointer indicating the starting address of the range of memory to be released.

count

The size, in bytes, of the range of memory to be released.

Return Value

This function always returns a value of noErr.

Discussion

If the starting address you supply to the UnholdMemory function is not on a page boundary, then UnholdMemory rounds down to the nearest page boundary. Similarly, if the specified range does not end on a page boundary, UnholdMemory rounds up the value you pass in the count parameter so that the entire range of memory is released.

Availability
Declared In
MacMemory.h

Deprecated in Mac OS X v10.5

FreeMem

Returns the total amount of free space in the current heap zone. (Deprecated in Mac OS X v10.5. There is no replacement function; you can assume that any reasonable memory allocation will succeed.)

long FreeMem (
   void
);

Return Value

Returns a fixed value for heap size that is compatible with most applications.

Discussion

In Mac OS 8 and 9, this function returns the total amount of free space in the current heap zone. In Mac OS X, this function always returns a large fixed value because applications run in a large, protected memory space.

Call the function MemError to get the result code. See “Memory Manager Result Codes.”

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.

Availability
Declared In
MacMemory.h

MaxBlock

Returns a fixed value for block size that is compatible with most applications. (Deprecated in Mac OS X v10.5. There is no replacement function; you can assume that any reasonable memory allocation will succeed.)

long MaxBlock (
   void
);

Return Value

The maximum contiguous space, in bytes, that you could obtain after compacting the current heap zone. MaxBlock does not actually do the compaction.

Discussion

In Mac OS X, this function always returns a large value because virtual memory is always available to fulfill any request for memory.

Call the function MemError to get the result code. See “Memory Manager Result Codes.”

Availability
Declared In
MacMemory.h

MaxMem

Returns the size, in bytes, of the largest contiguous free block in the current heap zone. (Deprecated in Mac OS X v10.5. There is no replacement function; you can assume that any reasonable memory allocation will succeed.)

Size MaxMem (
   Size *grow
);

Parameters
grow

On return, the maximum number of bytes by which the current heap zone can grow. After a call to MaxApplZone, MaxMem always sets this parameter to 0.

Return Value

The size, in bytes, of the largest contiguous free block in the zone after the compacting and purging.

Discussion

In Mac OS 8 and 9, the MaxMem function compacts the current heap zone and purges all relocatable, unlocked, and purgeable blocks from the zone. If the current zone is the original application zone, the grow parameter is set to the maximum number of bytes by which the zone can grow. For any other heap zone, grow is set to 0. MaxMem does not actually expand the zone or call the zone’s grow-zone function.

In Mac OS X, the MaxMem function returns a large fixed value because applications run in a large, protected memory space.

Call the function MemError to get the result code. See “Memory Manager Result Codes.”

Availability
Declared In
MacMemory.h

StackSpace

Returns the amount of space between the bottom of the stack and the top of the application heap. (Deprecated in Mac OS X v10.5. There is no replacement; this function was included to facilitate porting legacy applications to Carbon, but it serves no useful purpose in Mac OS X.)

long StackSpace (
   void
);

Return Value

The current amount of stack space, in bytes, between the current stack pointer and the application heap.

Discussion

Usually you determine the maximum amount of stack space needed before you ship your application. Thus this function is generally useful only during debugging to determine how big to make the stack. However, if your application calls a recursive function that conceivably could call itself many times, that function should keep track of the stack space and take appropriate action if it becomes too low.

Call the function MemError to get the result code. See “Memory Manager Result Codes.”

Special Considerations

StackSpace must not be called at interrupt time, as it may alter location MemErr.

Availability
Declared In
MacMemory.h

TempDisposeHandle

Releases a relocatable block in the temporary heap. (Deprecated in Mac OS X v10.5. Use DisposeHandle instead; Mac OS X does not have a separate temporary memory heap.)

void TempDisposeHandle (
   Handle h,
   OSErr *resultCode
);

Availability
Declared In
MacMemory.h

< Previous PageNext Page > Hide TOC


© 2003, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-06-27)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.