Cast not your Perl before swine?
Dave Smith
dave at thesmithfam.org
Tue Dec 18 10:41:25 MST 2007
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
More information about the PLUG
mailing list