After 24 hours of the server restart, I have taken the heap dump of my production JVM. Its about 1.5GB.
After given it to the Eclipse Memory Analyzer, the size comes to 140MB!!(Eclipse Memory analyzer parsed it and removes all the unreachable objects.) The Eclipse Memory analyzer shows that, the Unreachable objects size is about 1.3GB!!
Can I assume that, after running the Full GC every hour by below JVM parameters, the unreachable objects should be cleaned up? Does the below JVM parameters forces Full GC which claims the unreachable objects (or) its related to RMI objects only?
I didn't think it was possible to "force" the garbage collector to execute.
Joined: Aug 05, 2005
Campbell Ritchie wrote:I didn't think it was possible to "force" the garbage collector to execute.
RMI distributed garbage collection runs at regular intervals. These two variables can be used to alter what that interval is.
Joined: Aug 28, 2006
Thanks for your replies.
Is there any way to 'request' Explicit GC(System.gc()) if we can't force it?
For our production, it would be very useful for us to clean up the unreachable objects in regular basis instead of having them on our heap and let the GC clean them when it is short by memory.
System.gc() is how you request GC. But the chances if you handling memory better than the JVM are very, very low: it'll reclaim memory when needed. This kind of manual memory management is almost *never* needed in server apps.
i think you asked a very sensitive question.... Ive seen quite a few threads flood with highly emotional responses about how "You can never force a GC" and "All you can do is suggest a GC".
Indeed. System.gc is the best way to go about it. But it depends on the platform. It has been known to not do anything(Quote kathy sierra and bert bates - scjp 6 ). In most of the platforms however for a very high percentage of times, it will run the GC. I know that whenever I have tried on windows, to test it, Ive seen it run. But this is not guaranteed. This is like saying the higher priority thread started first will run first. Even though this is true most of the times, its not something you can rely on.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com