aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes finalize() doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "finalize() doubt" Watch "finalize() doubt" New topic
Author

finalize() doubt

saloni jhanwar
Ranch Hand

Joined: Feb 09, 2012
Posts: 583

I am not getting output of my finalize(),please help me to get it


Tell the difficulties that i am difficult.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18120
    
  39

saloni jhanwar wrote:I am not getting output of my finalize(),please help me to get it



Basically, the finalize() method is called as part of the GC process -- but the GC runs when the JVM needs memory. The JVM doesn't need memory to exit -- when your program (the main() method) finishes, the JVM will just exit.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
saloni jhanwar
Ranch Hand

Joined: Feb 09, 2012
Posts: 583

Henry Wong wrote:
Basically, the finalize() method is called as part of the GC process -- but the GC runs when the JVM needs memory. The JVM doesn't need memory to exit -- when your program (the main() method) finishes, the JVM will just exit.

Henry


Can you do something with my program so i can see that finalize() really works
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18120
    
  39

saloni jhanwar wrote:Can you do something with my program so i can see that finalize() really works


First, since you are not using threads, don't let your main() method finish. If it does, the JVM will exit. Second, you can request a GC via the gc() method of the Runtime class. If you didn't start your JVM configured to ignore those requests, it should do a GC cycle.

Henry
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
saloni jhanwar wrote:Can you do something with my program so i can see that finalize() really works

saloni jhanwar
Ranch Hand

Joined: Feb 09, 2012
Posts: 583

John Jai wrote:
saloni jhanwar wrote:Can you do something with my program so i can see that finalize() really works



Hmm good idea thanks John J.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: finalize() doubt
 
Similar Threads
Distributing files in round robin manner
Please rectify this code on anonymous classes
loading a csv file
Float Wrapper Class -- accept double
What does a "one to many" relationship mean