Comment by pcwalton
13 years ago
> If the ref counting is manual or optimized, it doesn't happen after every assignment, only ones which change object ownership.
The Rust compiler does this. Even so, 19% of the binary size in rustc is adjusting reference counts.
I am not exaggerating this. One-fifth of the code in the binary is sitting there wasted adjusting reference counts. This is much of the reason we're moving to tracing garbage collection.
All of those optimizations that you're talking about (for example, packing reference counts into the class pointer) will make adjusting reference counts take even more code size.
> As for not allowing cycles, I consider that a feature. The headache of memory management doesn't go away with GC.
The fact that memory management is still an issue doesn't mean that we shouldn't make it work as well as we can.
In large software projects, cycles are a persistent issue. Gecko had to add a backup cycle collector over its reference counting framework, and observed memory usage decreased significantly once it was implemented.
That's the evolution Python went through as well: reference counting, then (in CPython 2.0) an adjunct cycle-collector, then (in PyPy) a non-reference-counting garbage collector.
Hopefully in future versions of PyPy an even better garbage collector. :-)