Skip to content
Advertisement

How to tell if one of the heap-generations is full?

We are experiencing some problems in our production environment, where we get an InvalidPropertyException from one of the compiled jsps (which one differs from time to time) after a bit of time. I have a suspicion that this is caused by something “disappearing” from the heap. Further, I suspect that this is due to one of the generations of the heap becoming full, so some objects “spill” into a different generation where it is eventually GC-ed.

What I am wondering is: Is it possible to automatically monitor the heap, and alert when one of the generations are full and there is a posibility for such a spill? This could either be programatically or through some configuration.. We have tried using JConsole, but only after the error has started occuring, and then everything looks OK, but what I would really like is to know what it looks like at the exact time when the error occurs (or actually a few minutes before), without having to manually monitor.

I have posted a more general question for this problem, which has some more details: Spring, NotReadablePropertyException and Glassfish version

Advertisement

Answer

I’m not going to say that it’s impossible that your problem is heap-related, but if it was it would indicate a serious and very major bug in the memory subsystem and garbage collector in the JVM. While of course not impossible, it’s highly, highly unlikely nonetheless as it would surely have been discovered by multiple other people and I have not heard anyone else reporting anything similar.

Basically, objects are never GC:ed while there is still at least one live reference to the object. Moving between generations in the heap has nothing to do with it, that is just background work done by the GC to optimize memory handling. In fact, not all JVM:s even have generations.

If you have objects that “disappear”, it’s either because you’re using WeakReference or SoftReference or because you simply de-reference the object in your code, making it eligible for reclamation.

If you post more details on your actual exception (stacktraces etc) and relevant code, perhaps someone here can help you find the problem.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement