Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding Finalize

 
santhosh kumar vk
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

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
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..

Ashok
 
Greg Charles
Sheriff
Posts: 2987
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that finalize is not guaranteed to run. The only guaranty you got is that it will not run more then once.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic