4 ms·
Reference counting has plenty of instruction specific atomic operations on common processors in use today (and no, GC routines need write barriers in most cases
by strmpnk 15y ago
Reference counting has plenty of instruction specific atomic operations on common processors in use today (and no, GC routines need write barriers in most cases that atomic counting is needed). But you're right, it's tricky, but that's why it's important to make all of that automatic and transparent to the programmer.
Delegation patterns are complex for lifetime management though that is why they have spent a good portion of their documentation on helping people understand when to use zeroing weak references which is a very easy fix for problems like this. Their heuristics work better than I imagined here. Still trickier than GC but much more consistent.
So far the downsides are pretty small relative to manual memory management and close to GC without trading off the consistency of manual memory management. I'd say "garbage collection without any of the nasty downsides" is more accurate in this case than not.