[...]
Not sure what you mean by "done automatically by the GC". If an
object is garbage collected,it means nothing held a reference to it.
Actually, it means that the object was not reachable. There may in fact
still be references to it (i.e. in other unreachable objects), but those
references themselves cannot be accessed and so the object is not
reachable.
Good clarification, thanks. The underlying point is the same, what
difference
would it make to the app as a whole?
I'm not really sure what your question means.
In terms of the question of the difference between "nothing held a
reference to it" and "is unreachable", there's a critical difference: GC
would not work nearly as efficiently if it worked as you described, because
it would take multiple collection iterations to free up objects that were
referenced within one or more levels of indirection.
With the "unreachable" implementation, objects are collected as soon as
they can be.