jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Regarding Finalize Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regarding Finalize" Watch "Regarding Finalize" New topic

Regarding Finalize

santhosh kumar vk
Ranch Hand

Joined: Aug 25, 2009
Posts: 151

This is santhosh i could not understand about finalise can you tell what is the use of finalize and how to call filalize
Ashok A Kumar

Joined: Jul 01, 2010
Posts: 19
Assuming that you have little understanding of Garbage collection

I think your question is about finalize method, Garbage collector will firstly call the finalize method (Implicitly), Whenever its ready to release the storage of your used object.

IMO , Don't call the finalize method explicitly on your own, finalize() can be used to observe and understand the process of garbage collection.

Wish you all success..

Greg Charles

Joined: Oct 01, 2001
Posts: 2967

Hi Santosh,

In theory, finalize() can free up non-memory resources used by a object that is no longer being used when the garbage collector runs. Non-memory resources could be a database connection, a file handle, or anything else really. I say in theory, because in practice, I've rarely used finalize() methods. You generally want to release shared resources as soon as you've finished with them, and not rely on the garbage collector to do it.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

The problem is that finalize is not guaranteed to run. The only guaranty you got is that it will not run more then once.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
I agree. Here's the link: http://aspose.com/file-tools
subject: Regarding Finalize
It's not a secret anymore!