• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GC question 2

 
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic