Reference counting is "worst" or "best" depending on your requirements. The kind of garbage collection all the "modern" JVMs like to do requires about FIVE TIMES as much RAM as reference counting.
Speaking of garbage collection, it is using reference counting itself. The difference is that a collection cycle counts up the references on the spot instead of tracking them continuously.
The Linux kernel uses reference counting quite a lot. It isn't the only thing used in the kernel, of course. RCU is another RAM hungry technique used there. But the counting seems to work rather well in a kernel, much better than garbage collection.
The Boost collection has some other reference counting options that can work better than shared_ptr, like the intrusive pointers which store the reference count inside the object, giving much better cache locality.
Posted Jan 18, 2009 21:29 UTC (Sun) by rwmj (guest, #5474)
[Link]
I'm assuming by "FIVE TIMES" you're referring to this paper. Unfortunately the paper is flawed
with respect to reference counting, because it doesn't include the reference counts
- it just assumes that the manually managed version "knows" somehow exactly
when to free stuff. With ref counts you bloat every object by 4-8 bytes, and
of course that has an effect on cache and memory, which they don't measure.
You can find a more
detailed response here.