This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GC question 2  RSS feed

 
Shawn Kuenzler
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


"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.
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this thread.
 
Shawn Kuenzler
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool. Thanks!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!