Comment by pizlonator

3 months ago

Yeah!

Also, the closest thing to a graph search in reference counting, as most of us understand it, occurs at a totally different level in the stack.

In a GC: the graph search is hidden from view and implemented in any number of clever ways by the language runtime. Or, if you’re implementing the GC yourself, it sits out of the way of normal operations on your “heap”.

In ref counting: down ref to zero triggers a destructor. That destructor can do anything. It so happens that if the type has reference counted references, then the destructor will, either automatically or manually, invoke downref operations. All of this is part of the language’s normal execution semantics.

To say that these things are alike is a stretch. You could use similar logic to say that anyone doing a graph search is collecting garbage

You seem to be referring to a reference counting scheme that is retrofitted into a language, where the application has the responsibility of indicating where, in an application-defined type, the references are to other objects.

That can be true of garbage collection also; it can be bolted on in a way that the application is responsible for providing a handler for traversing objects during marking.

(Of course, it is vastly less likely that a marking traverser would be doing anything other than its job of recursing or otherwise indicating pointers to be traversed, whereas finalization routines will mix the downing of references with other resource clean up.)