HLockHi
HLockHi
Move a block as high as possible and lock it Handle theHandle; handle to move high and lock HLockHi moves the data referenced by theHandle as high as possible in the heap zone and locks it. By using this routine to lock a handle, you can avoid
some heap fragmentation.
theHandle is a handle leading to a relocatable memory block. It is typically a
nilHandleErr (-109) theHandle is NIL
memWZErr (-111) Illegal operation on a free block
memLockedErr (-117) theHandle is currently locked
convenient replacement for this pair of procedures.
HLockHi moves the handle's data upward toward the top of the heap. It stops looking higher when it en counters any relocatable block, a locked
relocatable block, or the last block in the heap.
Of course, it takes time to move chunks of data around in memory, but a
fragmented heap can bring your application to its knees. It is a good
practice to pay special attention to locked and nonrelocatable blocks. If you
intend to lock a block for any length of time, or during a period in which a
nonrelocatable block will be allocated, you are advised to use MoveHHi. The real problem with fragmentation is that the Memory Manager won't
move relocatable blocks around nonrelocatable blocks (e.g., all Handles below a Ptr must stay below it).