aspose file tools*
The moose likes Java in General and the fly likes finalize  method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "finalize  method " Watch "finalize  method " New topic
Author

finalize method

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Hi,
Programmers are advised not to depend on finalize method being called by the JVM.
The EJB spec says that a bean class should not overide the method at all.
I think this method should be put into a trash bin. Why should we have the method when it is of no use?


Groovy
Ouaknin lionel
Greenhorn

Joined: Sep 12, 2003
Posts: 14
legacy ?


"Nobody will ever need more than 256 kb of ram" -Bill Gates
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Can you please explain more?
Jason Davies
Greenhorn

Joined: Sep 18, 2003
Posts: 14
The finalize() method is sometimes used to free memory allocated by native methods - memory that wouldn't be freed by the garbage collector.
They may also be used to prevent sloppy use of your class by ensuring non-memory finite resources such as file handles or sockets are released.
See this related article on JavaWorld: http://www.javaworld.com/javaworld/jw-06-1998/jw-06-techniques_p.html
Hope that helps,
--Jase


<a href="http://www.netspade.com/" target="_blank" rel="nofollow">http://www.netspade.com/</a> - Web programming articles and tutorials.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

JVM is not required to call the finalize method. What happpens then?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: finalize method
 
Similar Threads
Garbage Collection
finalize method
Is this true?
adv and disadv of constructor and finalizer method
Finalization Method