Why doesn't JVM return memory to OS?
843811Oct 17 2003 — edited Oct 22 2003Hi, I did some google and search on this forum but didn't find any related discussion, so here it goes.
I wonder why there isn't a mechanism for GC to release memory back to the OS. This comes from a project I'm working on that runs as a background daemon and uses memory in a "burst pattern". It usually sleeps and requires just a little memory, only for a couple of times a day, it does some work which requires a lot of memory.
Now I have configured to start this daemon with, say, "-Xms4M -Xmx256M". But that works only until the first "burst", after which the JVM always hangs onto the large memory trunks even though inside the JVM my program has set the references to null and caused these trunks to be garbaged collected.
Shouldn't there be some switch in the JVM to allow releasing memory back to the underlying OS after a certain period?
--J.X.