"Branden" <[EMAIL PROTECTED]> writes:
> Piers Cawley wrote:
> >"Branden" <[EMAIL PROTECTED]> writes:
> >> Of course, C++ has no GC, which is a good thing, but you can always
> >> fake it with Refcounts, which is much more efficient, and easily
> >> feasable with C++.
> >
> >Err... current research shows that the refcount approach is one of the
> >slowest forms of GC, and it doesn't even do the job properly.
> >
> >--
> >Piers
>
>
> I actually don't understand how traversing a graph can be faster than
> incrementing/decrementing/testing for zero on a refcount. I believe you, but
> I just don't understand. Could you point me to some URLs that talk about
> this?
There's a jolly good book on this called (would you believe) 'Garbage
Collection'. The crux of the matter would appear to be that with
refcounts you have to do a pretty small amount of work very, very
often. With a well designed GC system you do a largish amount of work
much less frequently. The total amount of work done tends to come out
higher in the refcounting scenario.
Consider:
for my $foo (@list_of_refs) {
...
}
This does N increments, N decrements and N comparisons. At least. A GC
system doesn't. And, unless a GC pass happens during the loop, no GC
overhead will be incurred.
--
Piers