• 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

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: 24203
44
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
  • 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.
 
Get me the mayor's office! I need to tell him about this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic