gc() suggests that the garbage collector should dispose of unused objects; runFinalization() suggests that it should run the finalize() methods of objects that are already queued for disposal.
Which one is preferred? Neither.You should never (with exceedingly few exceptions that come up only in very obscure situations in tool and platform development) call either -- period. Leave the garbage collector alone to do its work -- it knows what it's doing.
Do they really? Is the GC in 1.5 better than the one in 1.4? The one in 1.4 does not know when it should collect garbage except for when the memory is low or some other object based metric. It does not seem to have a conciousness for when the user is taking a brake.
Seems like the GC is triggered by action rather than inaction. So given the opportunity, I'd call GC if I knew for sure my program was idle. [ July 07, 2006: Message edited by: Mr. C Lamont Gilbert ]
calling gc does nothing (or rather is not guaranteed to do anything). Calling it explicitly is therefore hardly ever something you should do, if and when the JVM needs memory it will find a place to do its thing.
JVM tends to find the wrong place to do its thing causing long pauses in my program. There is always the incremental GC but that slows the whole thing down noticeably even on a very fast computer. I'm still talking 1.4 here as 1.5 may be better, I don't know.
Nothing beats calling the GC when your program is idle. I highly recommend it. Knowing when its idle may be tricky, but if you do, a call to gc can only help. Its certainly not worse than having the user maximize the window to a long pause.
Originally posted by Ernest Friedman-Hill: gc() suggests that the garbage collector should dispose of unused objects; runFinalization() suggests that it should run the finalize() methods of objects that are already queued for disposal.
so, runFinalization() suggest's that it should run finalize() methods of all the obejcts
what happens if i am not calling finalize() method ?will JVM do for me b4 GC ing ??? :roll:
A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad: