Levi Pearson wrote:
The nice thing about the kind of garbage collector that Java uses is
that allocation becomes REALLY cheap.  The C malloc actually has to do
a fair bit of work to figure out where it can allocate memory from,
since repeated mallocs and frees can cause heap fragmentation.  A
compacting collector makes sure that heaps aren't fragmented, so
allocation becomes a simple pointer increment.  That's the sort of
thing that computers do REALLY fast. :)

I don't understand how the C program's heap got fragmented when all the mallocs were of the same size, and freed in order. This means that they *should* all end up getting allocated in the exact same address (or at least close), which would require almost no searching. Seems to me like it shouldn't be *that* much slower than the Java allocator.

--Dave

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to