Most books mention that ONLY objects with no references will be garbage collected. However, Mughal & Rasmussen states that an object is only eligible for garbage collection if the only references to the object are from other objects that are also eligible for garbage collection. In other words, they still have references. Does anybody know how to answer if such question appears in exam?
[This message has been edited by Kevin Yip (edited May 05, 2001).]
Hi Kevin, I understand your difficulty. The best way to answer the questions on Garbage collection is use a paper and pen. Assign the reference to the object created, do so meticulously after each execution and as soon as you see that a particular object is not reacheable by any refernce, then the JVM will find the object that has been derefenced eligible for garbage collection. There are many discussion happening in this forum you may search and refer to them for more insights. Ravindra Mohan ------------------