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.
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
A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
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.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
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