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 theMoveHHi
procedure, 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
TheMoveHHi
procedure attempts to move the relocatable block referenced by the handleh
upward until it reaches a nonrelocatable block, a locked relocatable block, or the top of the heap.
By using the
- WARNING
- If you call
MoveHHi
to move a handle to a resource that has itsresChanged
bit set, the Resource Manager updates the resource by using theWriteResource
procedure 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.MoveHHi
procedure 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
procedure to move blocks you plan to lock for long periods of time. TheMoveHHi
procedure 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 theReserveMem
procedure 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 theReserveMem
procedure 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
procedure cannot move locked blocks; be sure to lock blocks after, not before, callingMoveHHi
.)
- Note
- Using the
MoveHHi
procedure 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 preventMoveHHi
from moving blocks to the top of
the heap.SPECIAL CONSIDERATIONS
Because theMoveHHi
procedure moves memory, you should not call it at interrupt time.Don't call
MoveHHi
on blocks in the system heap. Don't callMoveHHi
from a desk accessory.ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit forMoveHHi
are
Registers on entry A0 Handle to move
Registers on exit D0 Result code RESULT CODES
noErr 0 No error nilHandleErr -109 NIL
master pointermemLockedErr -117 Block is locked