This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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!
 
Consider Paul's rocket mass heater.
 
subject: GC question 2
 
Similar Threads
que on GC
Master exam doubt
Error in SJCP 5 Learnkey Bonus exam, finalize() / garbage collection
finalize() called more than once
Garbage collection..