[net.micro.mac] What really happens during a compaction?

burnard@lll-crg.UUCP (David Burnard) (08/28/85)

Okay everybody, get out your copies of IM and your debuggers for this
one. For an upcoming book on using the Toolbox from C, I came upon the
following interesting question.

When the heap gets compacted, it tries to move relocatable blocks
toward the bottom of the heap to merge together the free blocks. If the
heap has become fragmented due to the presence of locked relocatable or
nonrelocatable blocks the situation gets a little murky. The big
question is: Will the Memory Manager pick up a relocatable block and
jump over a nonrelocatable one during a compaction? Or do the
relocatable blocks just slide towards low memory until they pile up on
the nearest nonrelocatable block.

Seems like it should be able to move blocks around the fixed ones, but
perhaps the algorithm is more complicated and judged not worth the
slowdown. I've tried all sorts of heap configurations and haven't
succeeded yet. IM neatly avoids the issue although the accompanying
pictures might suggest that the blocks cant be moved over a fixed block.

Please post directly to me at burnard@lll-crg an I'll summarize for the
net in case anybody else in interested. After all the nice thing about
the Toolbox is that you dont have to deal with things like this, except
when a little voice somewhere (my C guru roommate) sez "Are you sure
about that?".

					    Dave Burnard

P.S. - The book in question will be out in November sometime from
       Sybex Books. Called Using the Macintosh Toolbox from C - or
       some permutation thereof. Authors are Fred Huxham, Jim Takatsuka
       and myself.