Is reference counting slower than GC?
It is well-known that the amortized cost of naive reference counting is considerably higher than that of a modern tracing garbage collector (regardless of whether you also support cycle collection). It is also well-known that non-naive RC-based approaches generally make it easier to achieve lower pause times (though cycle collection may throw a spanner in the works).<p>Attempts to bring amortized RC performance up to par with tracing GCs [1] generally require an underlying machinery that is just as complicated as that of a tracing GC; you will typically rely on stack scanning to implement deferred reference counting or non-trivial compiler optimizations with the goal to eliminate or reduce the overhead of local pointer assignments and you may still be left with a more expensive write barrier, so you may also have to gun for a hybrid approach.<p>Advantages of naive RC are that it is easier to add to an existing language without extensive compiler&#x2F;runtime support (assuming you don&#x27;t need cycle detection) and that it can more easily coexist with other approaches to memory management; amortized cost is not one of them.<p>[1] Such as <a href="https:&#x2F;&#x2F;www.cs.purdue.edu&#x2F;homes&#x2F;hosking&#x2F;690M&#x2F;urc-oopsla-2003.pdf" rel="nofollow">https:&#x2F;&#x2F;www.cs.purdue.edu&#x2F;homes&#x2F;hosking&#x2F;690M&#x2F;urc-oopsla-2003...</a>