L
Laird Nelson
In many object oriented designs, the model calls for something like this:
+---+1 1+---+
| A +-----+ B |
+---+ +---+
....i.e. an A object has a reference to a B object, and that B object has
a reference to the A object.
Suppose the only reference to this little hairball is to A, e.g. suppose
that A is put into a container like a web session or a hashtable or
something like that.
Now suppose that /that/ reference is set to null, i.e. the A-B graph is
removed from the hashtable or session, and there is nothing else that
has a reference to that graph. In my understanding, this means that the
A-B graph is not reachable, and hence is eligible for cleaning up by the
garbage collector, even though B will never release its reference to A,
and A will never release its reference to B.
So: /will/ this situation prevent the garbage collector from reclaiming
the memory occupied by the A-B graph? My colleague says yes; I say no.
Where could I go to find out more information on this?
Thanks,
Laird
+---+1 1+---+
| A +-----+ B |
+---+ +---+
....i.e. an A object has a reference to a B object, and that B object has
a reference to the A object.
Suppose the only reference to this little hairball is to A, e.g. suppose
that A is put into a container like a web session or a hashtable or
something like that.
Now suppose that /that/ reference is set to null, i.e. the A-B graph is
removed from the hashtable or session, and there is nothing else that
has a reference to that graph. In my understanding, this means that the
A-B graph is not reachable, and hence is eligible for cleaning up by the
garbage collector, even though B will never release its reference to A,
and A will never release its reference to B.
So: /will/ this situation prevent the garbage collector from reclaiming
the memory occupied by the A-B graph? My colleague says yes; I say no.
Where could I go to find out more information on this?
Thanks,
Laird