Unfortunately, there is a lot of sloppy use of terminology surrounding garbage collection, which causes much confusion. A "disposer" or "finalizer" does not actually destroy an object, but rather serves to delay the destruction of an object which would otherwise be eligible for destruction, until after it has had a chance to put its affairs in order (i.e. generally by letting other things know that their services are no longer required).
It's simplest to think of the "stop the world" garbage collector as performing the following steps, in order:
- Untag all items which are new enough that they might be considered "garbage".
- Visit every garbage-collection root (i.e. thing which is inherently "live"), and if it hasn't been copied yet, copy it to a new heap, update the reference to point to the new object, and and visit all items to which it holds references (which will copy them if they haven't been copied). If one visits an item in the old heap that had been copied, just update the reference one used to visit it.
- Examine every item that has registered for finalization. If it hasn't yet been copied, unregister it for finalization, but append a reference to it on a list of objects which need to be finalized as quickly as possible.
- Items on the immediate-finalization list are considered "live", but since they haven't yet been copied yet, visit every item on that list and, if not yet copied, copy it to the new heap and visit all items to which it holds references.
- Abandon the old heap, since nobody will hold references to anything on it anymore.
It's interesting to note that while some other garbage-collection systems work by using double-indirected pointers for references, the .net garbage collector (at least the normal "stop the world" one) uses direct pointers. This increases somewhat the amount of work the collector has to do, but it improves the efficiency of code that manipulates objects. Since most programs spend more of their time manipulating objects than they spend collecting garbage, this is a net win.