Is this really true for all VMs using any GC-algorithm?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.
About Question com.enthuware.ets.scjp.v6.1.799 :
Moderator: admin
About Question com.enthuware.ets.scjp.v6.1.799 :
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.1.799 :
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.
HTH,
Paul.
-
- Posts: 5
- Joined: Thu Apr 19, 2012 2:18 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.1.799 :
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?
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 :
The difference is that in this case the list is static.
Who is online
Users browsing this forum: No registered users and 7 guests