The GC is smart enough to follow paths in graphs of objects in order to check if the existing references to some object are reachable. It can even detect cycles (like, in your case, if be held a reference to a and a held a reference to b.
Once there are no hard references to be there is no way to reach its reference to a, so both are eligible for garbage collection as far as I know.
Generally, you shouldn't care. It's not reachable, and you should let the garbage collection worry about the rest. Since it becomes unreachable, it should be eligeble for collection immediately.
– Nik May 13 at 13:22 1 Then it is likely you are looking in the wrong place ;) – Martijn May 13 at 13:25 @user587465 This could arguably be a good reason since you cannot count on the GC ever running during a program execution. That is, your program could finish without a single collection cycle ever run.So unless you are dealing with Weak, Soft or Phantom references or with finalizers, the reason of your problem is very unlikely to be related to this. Still, if you can describe the problems, perhaps we could offer more ideas of where to look for the root cause.
– edalorzo May 13 at 13:31.
There are also some flags you can use when running a Java program (at least with the Sun JVM) that will give some debugging information about what goes on during garbage collection. Try the -verbose:gc option. download.oracle.com/javase/6/docs/techno....
Object A will also become eligible garbage collection as soon as you set ObjectB to null (* condition is ObjectA is not referred by any other live object). This condition is known as "Island of Isolation". Here is a nice explanation of this situation.(Here is one more explanation from SCJP book).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.