Important: The information in this document is obsolete and should not be used for new development.
MoveHHi
If you plan to lock a relocatable block for a short period of time, use theMoveHHiprocedure, which moves the block to the top of the heap and thus helps prevent heap fragmentation.
PROCEDURE MoveHHi (h: Handle);
h- A handle to a relocatable block.
DESCRIPTION
TheMoveHHiprocedure attempts to move the relocatable block referenced by the handlehupward until it reaches a nonrelocatable block, a locked relocatable block, or the top of the heap.
By using the
- WARNING
- If you call
MoveHHito move a handle to a resource that has itsresChangedbit set, the Resource Manager updates the resource by using theWriteResourceprocedure to write the contents of the block to disk. If you want to avoid this behavior, call the Resource Manager procedureSetResPurge(FALSE)before you callMoveHHi, and then callSetResPurge(TRUE)to restore the default setting.![]()
MoveHHiprocedure 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
MoveHHiprocedure to move blocks you plan to lock for long periods of time. TheMoveHHiprocedure 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 theReserveMemprocedure 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
MoveHHieach time slows down your application, you might consider leaving the block always locked and calling theReserveMemprocedure 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
MoveHHiprocedure cannot move locked blocks; be sure to lock blocks after, not before, callingMoveHHi.)
- Note
- Using the
MoveHHiprocedure 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 preventMoveHHifrom moving blocks to the top of
the heap.![]()
SPECIAL CONSIDERATIONS
Because theMoveHHiprocedure moves memory, you should not call it at interrupt time.Don't call
MoveHHion blocks in the system heap. Don't callMoveHHifrom a desk accessory.ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit forMoveHHiare
Registers on entry A0 Handle to move
Registers on exit D0 Result code RESULT CODES
noErr 0 No error nilHandleErr -109 NILmaster pointermemLockedErr -117 Block is locked