• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding finalize method

 
Raj chiru
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 48940
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch , Harpreet Ahuja
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic