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 Beginning Java and the fly likes Regarding finalize method 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 » Java » Beginning Java
Bookmark "Regarding finalize method" Watch "Regarding finalize method" New topic
Author

Regarding finalize method

Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 141
Hi Friends,
I'm trouble with finalize and garbage collection.
when an object is eligible for garbage collection,does the finalize() method get called immediately on that object?
Harpreet Ahuja
Greenhorn

Joined: Feb 26, 2010
Posts: 1
Finalize method can be used before garbage collector claims the memory used by the object.It can't be guaranteed when garbage collector will be invoked so you should not release any critical memory resources into this method.For that you can use the finally method with try catch block.

Its like a last wish notice before GC hangs the object to death...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37907
    
  22
Welcome to the Ranch , Harpreet Ahuja
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding finalize method
 
Similar Threads
finalize
GC from j@whiz
Garbage collection questin from Danchisolm
Garbage collection will be triggered and finalize method will be called ?
Garbage Collection