Re: What is the use of System.gc and Runtime.gc?
"Luc The Perverse" <sll_noSpamlicious_z_XXX_m@cc.usu.edu> wrote in message
news:vngqq3xqfr.ln2@loki.cmears.id.au...
"Oliver Wong" <owong@castortech.com> wrote in message
news:F6rCg.153$Ch.73@clgrps13...
<laredotornado@zipmail.com> wrote in message
news:1155150898.459028.296870@i3g2000cwc.googlegroups.com...
Hello,
I read that in Java 1.4, garbage collection cannot be forced and calls
to System.gc() and Runtime.gc() are not reliable because they can defer
to threads of higher priority. Then what exactly happens when
System.gc and Runtime.gc are called and when (if ever) do they get
executed?
These methods get executed as soon as you call then. System.gc()
simply calls Runtime.getRuntime().gc(). Runtime.gc() invokes a native
method in the virtual machine. What the VM does at this point is
implementation dependent. I believe a legal implementation is to just
ignore the method call completely.
But that is not the way is actually done in the Java VM by Sun for common
platforms . . . . is it?
I guess when Sun finishes open-sourcing their JVM, we'll find out! ;D
Actually, from what I understand, you can configure what garbage
collection algorithm Sun's JVM will use via command line arguments, so
probably what Sun's JVM does depends heavily on which garbage collector its
using.
- Oliver