Is this function pure?
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Wed Sep 19 14:25:58 PDT 2007
Bill Baxter wrote:
> The 'fast allocation' claim may be true of generational GCs or other
> fancy GCs, but D currently has a mark&sweep type.
Yes, AFAIK the 'fast allocation' is mostly true of garbage collectors
that move objects that aren't collected, since they have all free memory
in a contiguous block and can just increment a pointer.
However, I can see /deallocation/ being faster with a GC since the cost
of explicit deallocation isn't just limited to the free/delete call; it
also often incurs the cost of tracking *when* to call them (which often
means using things like reference counts, which in a multithreaded app
need a mutex...).
Also, a GC gets to postpone memory deallocation until it's actually
needed, which can sometimes mean they don't have to do it at all (if
your program doesn't allocate all that much).
Note: I'm not saying using a GC is necessarily faster (since I don't
have the numbers), just that I can see how it *could* be.
Of course, there's also the programmer convenience factor :).
More information about the Digitalmars-d
mailing list