Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

finalize() doubt

 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not getting output of my finalize(),please help me to get it
 
Henry Wong
author
Marshal
Pie
Posts: 22119
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 22119
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saloni jhanwar wrote:Can you do something with my program so i can see that finalize() really works

 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic