Page 1 of 1
About Question com.enthuware.ets.scjp.v6.1.799 :
Posted: Mon Mar 12, 2012 8:15 pm
by ETS User
Thus, in the next GC cycle when the GC tries to reclaim the memory of FinalizeTest object, it sees that it has a valid reference and this ignores the object.
Is this really true for all VMs using any GC-algorithm?
Re: About Question com.enthuware.ets.scjp.v6.1.799 :
Posted: Tue Mar 13, 2012 2:59 pm
by admin
If there is a live reference to any object, the GC will not destroy that object. This is guaranteed to be true for any GC algorithm. So if you were to create such a reference in finalize method, the object will not be destroyed.
HTH,
Paul.
Re: About Question com.enthuware.ets.scjp.v6.1.799 :
Posted: Wed Apr 25, 2012 9:41 am
by normc
My interpretation was that it will be eligible for GC because even though the List contains a reference, and FinalizeTest has a reference to Resurrecter, nothing points to FinalizeTest, so its composite objects are eligible for GC.
From Mughal, p391: "...we can conclude that if a composite object becomes unreachable, its constituent objects also become unreachable, barring any reachable references to the constituent objects."
However, I do see that there are pointers to FinalizeTest in the List. Is this not a similar situation where 2 objects that point to each other are eligible for GC?
Re: About Question com.enthuware.ets.scjp.v6.1.799 :
Posted: Tue Sep 04, 2012 4:00 am
by Pegazz
The difference is that in this case the list is static.