Concurrent Immediate Reference Counting
Memory management for optimistic concurrency in unmanaged programming languages is challenging. Safe
memory reclamation (SMR) algorithms help address this, but they are difficult to use correctly. Automatic
reference counting provides a simpler interface, but it has been less efficient than SMR algorithms. Recently,
there has been a push to apply the optimizations used in garbage collectors for managed languages to elide
reference count updates from local references. Notably, Fast Reference Counter, OrcGC, and Concurrent
Deferred Reference Counting use SMR algorithms to protect local references by deferring decrements or
reclamation. While they show a significant performance improvement, their use of deferral may result
in growing memory usage due to slow reclamation of linked structures, and suboptimal performance in
update-heavy workloads.
We present Concurrent Immediate Reference Counting (CIRC), a new combination of SMR algorithms with
reference counting. CIRC employs deferral like other modern methods, but it avoids their problems with
novel algorithms for (1) immediately reclaiming linked structures recursively by tracking the reachability of
each object, and (2) applying decrements immediately and deferring only the reclamation. Our experiments
show that CIRC’s memory usage does not grow over time and is only slightly higher than the underlying
SMR. Moreover, CIRC further narrows the performance gap between the underlying SMR, positioning it
as a promising solution to safe automatic memory management for highly concurrent data structures in
unmanaged languages.