wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes GC question 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "GC question 2" Watch "GC question 2" New topic
Author

GC question 2

Shawn Kuenzler
Ranch Hand

Joined: Apr 16, 2006
Posts: 73


"at //do stuff at least one Phoenix object is eligible for GC and the JVM could have invoked the finalize() method at least once" The first Phoenix object is the only one eligible for GC.

Can someone explain this? I don't understand why only the first one is eligible.


SCJP 1.5
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
this thread.
Shawn Kuenzler
Ranch Hand

Joined: Apr 16, 2006
Posts: 73
That thread explains that the JVM can call finalize() only once, despite how many times it's programatically called.

But I still don't see why only the first Phoenix object is eligible for GC.
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
new Phoenix().finalize(); // p2 reference to it (first one)
new Phoenix().finalize(); // p2 reference to it (second one and no one reference to first one now
Phoenix p3 = new Phoenix(); // p3 referecen to it
Shawn Kuenzler
Ranch Hand

Joined: Apr 16, 2006
Posts: 73
Cool. Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GC question 2