This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design 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: 20997
76
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: 20997
76
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