I'm trying to troubleshoot a permgen leak, and wanted to ask you folks for your opinions on how to interpret the output from jmap -permstat.
Let's say that I have a jmap -permstat report, like this:
class_loader classes bytes parent_loader alive? type
<bootstrap> 4791 25941568 null live <internal>
0x00000007203ed508 0 0 0x00000007203ed228 dead com/example/object/SomeObjectType$FirstClassLoader@0x0000000something1
0x000000071dc17620 1 3056 0x0000000705e692a8 dead sun/reflect/DelegatingClassLoader@0x0000000something4
0x000000071f26a898 0 100 null dead com/example/object/SomeClassLoader@0x0000000something3
0x0000000721c6dba0 0 100 null dead com/example/object/SomeClassLoader@0x0000000something3
0x000000071e36df20 0 100 null dead com/example/object/SomeClassLoader@0x0000000something3
0x000000072157c1b8 339 2069112 0x000000072157b8d8 dead com/example/object/SomeObjectType$SecondClassLoader@0x0000000something2
0x00000007128b7830 1 1912 0x0000000700056db8 dead sun/reflect/DelegatingClassLoader@0x0000000something4
0x0000000707634360 1 3088 0x0000000700056db8 dead sun/reflect/DelegatingClassLoader@0x0000000something4
Here's how I would interpret the above output-- please correct any mistakes that I've made in doing so.
The values in the "type" column aren't unique. We see some objects that appear three times. However, the class_loader value is unique across all three; therefore, each of them is a distinct object, occupying permgen space. In this example, each one occupies 100 bytes; therefore, 300 bytes of permgen space are being occupied by objects of type SomeClassLoader.
If the classes value is non-zero, then this object must be a class loader of some kind, and this refers to the number of classes it references. (Note: In the actual file, those three objects have zeroes in the bytes column; I've added values for this example. In actual practice, I'm guessing that if there is a 0 in the classes column, there's no way the bytes value can be anything but zero.)
If the alive value is "dead", that means that the object is ready to be garbage-collected, but the JVM is not doing so. There's a separate discussion to be had as to reasons why this might be the case.
If there is a value in the parent_loader column, then this is an object that is referenced by another class loader, and cannot be garbage collected until that object is garbage collected.
Finally: 1) If I see 500 lines on the report that all list the same type, 2) but they list different class_loader values, 3) then I can add up the values in the bytes column 4) and this will accurately represent how much permgen space is being occupied by objects of that type.
Is this correct? Thanks!