Has anyone being seeing strange behaviour(s) with the GC in the latest Sun JVM?
I had major problems with the JVM’s ultra-greediness on memory when doing some NIO stuff (c.f. my post in networking some time back). Eventually, I moved all the other servers and daemons on to separate machines, so that the server with the JVM is not hosting anything else (which helps to prevent it from crashing linux!) although it does do X11.
I now have a nice simple situation where the JVM does approx 10 streamed parallel request/responses from a remote client, totalling around 50k of data, and takes 295Mb mem to do it. That eats heavily into swap space, so it takes minutes to recover, but still has the almost 300Mb mem usage…
…and yet a System.gc() at any time afterwards instantly (less than 2 seconds) recovers 170+ Mb of that. What’s bizarre is that the JVM apparently happily takes so much memory that it turns a sub 1-second set of processing and turns it into a 2-minute processing (because of the huge delays for huge amounts of mem-swapping!) but doesn’t feel any need to reclaim the memory.
Have we got hold of a new GC recently and I just didn’t notice? Does anyone know of a way to tell it not to be such a greedy **** and that virtual memory is not “there for the taking”, it’s “to be used sparingly” (I’d turn off swap entirely if it were just up to me ;)).
Incidentally, even post-GC it’s still using 128Mb, which is almost twice what it was typically using before changes to the NIO code and the upgrade from 1.4.2 to 1.4.2_04…
EDIT: although we get better performance in the 1.5 beta (uses 100Mb less memory for exactly the same test case) we haven’t yet regressed a version, so haven’t been able to rule-out a JVM-regression bug