Reference counting is ownership bookkeeping: every reference bumps a counter, every release decrements it, and at zero the object frees itself — immediately and deterministically. This diagram follows one object from allocation at count one, through retains and releases as aliases form and die, to the final release that deallocates it on the spot, no GC pause required. The ordering matters because the mechanism's weakness is structural: two objects referencing each other never reach zero, so a cycle collector must run separately to find them. The diagram shows both paths — the happy straight-line free and the cycle case that requires tracing. The done stage shows the deallocated memory returned to the allocator, and the balance check that catches leaked references.
Reference Count Lifecycle
Reference counting lifecycle: retain and release, deterministic freeing at zero, cycle detection, and the balancing act.
The Runtime Theory Team07 stages
trace / request.md
readyThe object is created with a reference count of one, owned by whoever allocated it. The count is stored in the object's header, next to its type info.