This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Doubt about garbage collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Doubt about garbage collection" Watch "Doubt about garbage collection" New topic
Author

Doubt about garbage collection

yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120


my question is memory is reclaimed for which object here??

finalize will run for which object?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

The garbage collector will call the finalize() method of an object it's about to dispose of. The finalize() you supply here is in the class CheckGC; since no CheckGC objects are ever created, this finalize() will never be called. If the Date class had a finalize() method, then it could be called many times because of all the Date objects being created and discarded.


[Jess in Action][AskingGoodQuestions]
 
wood burning stoves
 
subject: Doubt about garbage collection
 
Similar Threads
y aint here class <classname>=new <classname> used and instead only class <classname> used
Garbage Collector program does not run
Garbage collection example code from K&B
finalize question
GC doubt