top | item 8615402

(no title)

CodeWithCoffee | 11 years ago

> Also you can use smart pointers to do automatic garbage collection.

Not quite. Smart pointers do automatic reference counting, which doesn't use a garbage collector.

discuss

order

srean|11 years ago

Well, reference counting is a form of garbage collection, just not a very good one.

It is incomplete in the sense cycles are not collected, one would need extra machinery for those. It is also not great about throughput, a part of the problem is that it dirties the cache too much. Locking the count (or avoiding it somehow) is another issue. On the other hand for many use cases better latencies are achieved with reference counting than with alternative forms of garbage collection, (but this depends on use cases).

If runtime data cannot have have cycles, garbage is not created at a phenomenal rate and you are quite worried about GC pauses, then reference counting is often a cheap and effective solution.

Regardless, it sure is garbage collection.

DSingularity|11 years ago

I think he is referring to scoped pointers.