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.

Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3742

16

posted Aug 18, 2010 06:51:03

0

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.

krishna bulusu
Ranch Hand

Joined: Aug 28, 2006
Posts: 185

posted Aug 18, 2010 07:19:06

0

Hi,

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.