• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

System.gc nad System.runFinalization

 
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
What is the actual difference between rnfinalization method and system.gc() methods
thanx
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cleanup: finalization and garbage collection
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They're very similar in many ways. The two most important ways being that a JVM could legally implement them both as empty methods, and that you generally shouldn't ever call them. runFinalization() is different in that it relates to a little-used (for good reason) Java feature, whereas gc() relates to an important feature.
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why i shouldn't call them in my application??? :roll:
and what if i use it explicitly, and call them in my webapplication?
will they force the JVM to run garbage collection as soon as these commands executed by JVM???

and what is runFinalization?can u please explain me abt it :roll:


thank u in advance

cinux
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can call System.gc(), but it isn't guaranteed to do anything at all. It may cause some, or all, eligible objects to be garbage collected, or may do nothing. The JVM knows better than you (or me) when to finalise and GC anyway.

99.9% of the time, when you think you need to call gc(), you don't. And that's doubly true of runFinalization().

Really, you don't need to bother with them. Move on.
 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic