I'm working on fixing the issue
java.lang.OutOfMemoryError: Metaspace
in the time of redeploy where running an web application (Apache Roller, Java EE weblogger software: https://roller.apache.org) on Tomcat 8.0.18.
I know the cause of the issue can be found via Eclipse Memory Analyzer, so I have got a heap dump in the time of OOME, that produced automatically by the JVM which running with
-XX:+HeapDumpOnOutOfMemoryError.
I can see there are 4 WebappClassLoader instances that should be garbage collected. but I'm not sure why these instances hasn't be garbage collected.
So here's my questions in Merge Shortest Paths to GC Roots => exclude all phantom/weak/soft/etc. references
screen for each WebappClassLoader
instances:
Does this mean PostgreSQL JDBC Driver (deployed on the server side) has a reference to RollerContext?
This looks like a instance of SoftEntryReference
has a reference to WebappClassLoader
, but I guess it is not a strong reference so it doesn't prevent theWebappClassLoader
to be garbage collected. am I wrong?
I have no idea what this means... What does this mean? Does WebappClassLoader
itself prevents to be garbage collected?
Like I wrote in 2, I guess it should be garbage collected because it's referenced by a SoftReference. Am I wrong?
Does this mean PostgreSQL JDBC Driver (deployed on the server side) has a reference to RollerContext?
Yes, it would seem so. Specifically by an exception object's backtrace held in a static variable.
Merge Shortest Paths to GC Roots => exclude all phantom/weak/soft/etc. references
[...]
This looks like a instance of SoftEntryReference has a reference to WebappClassLoader, but I guess it is not a strong reference
[...]
Like I wrote in 2, I guess it should be garbage collected because it's referenced by a SoftReference. Am I wrong?
You're wrong.
You're not looking at soft references as far as the garbage collector is concerned. Only one field in a soft reference object is not-strong and that's the referent
field.
Looking inside the JDK's java.lang.ref.Reference<T>
class you will see that there are other fields. And you will also note that SoftReference
is subclassable and thus can have additional fields. All non-referent fields are strong references.
MAT indicates that the stuff you're looking at is held by chains of discovered
fields, which means the reference objects are certainly held alive, even if their referent has possibly been reclaimed.
I have no idea what this means... What does this mean? Does WebappClassLoader itself prevents to be garbage collected?
This is explained in the eclipse docs: It's a GC root because a lock is held on that object and because it's currently handled by native code, e.g. JNI.
It's the first google result for "eclipse mat busy monitor". Please do your research.