wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Garbage collection will be triggered and finalize method will be called ? 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 "Garbage collection will be triggered and finalize method will be called ?" Watch "Garbage collection will be triggered and finalize method will be called ?" New topic
Author

Garbage collection will be triggered and finalize method will be called ?

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
I have some code in finalize method and assume that the object always in use and never become eligible for garbage collection ,now if the JVM closes then what what wll happen
Garbage collection will be triggered and finalize method will be called ?
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3581
    
  14

No. When the JVM closes, that's that. Nothing happens any more.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

You can try to use Runtime.getRumtime().addShutdownHook(...) but that's also not guaranteed to run if the JVM exits abruptly.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage collection will be triggered and finalize method will be called ?
 
Similar Threads
Garbage Collection Problem
finalize......
Quick Q concerning GC
finalize() method doubt........
Garbage Collection