Intro
Reading about some issues with jvm here and I found that recently that jmap is actually an estimation based on <sizes for the different types of data a classloader loads>
jmap
Jmaps is used to verify several memory statistics from the jvm. I mean, it’s quite useful.
This tutorial is very helpful btw
jmap failure
Sometimes this estimation might fail quite a bit as in this case.
sun.jvm.hotspot.tools.PermStat.computeSize
:
private long computeSize(InstanceKlass k) {
long size = 0L;
// the InstanceKlass object itself
size += k.getObjectSize();
// Constant pool
ConstantPool cp = k.getConstants();
size += cp.getObjectSize();
size += objectSize(cp.getCache());
size += objectSize(cp.getTags());
// Interfaces
size += arraySize(k.getLocalInterfaces());
size += arraySize(k.getTransitiveInterfaces());
// Inner classes
size += objectSize(k.getInnerClasses());
// Fields
size += objectSize(k.getFields());
// Methods
ObjArray methods = k.getMethods();
int nmethods = (int) methods.getLength();
if (nmethods != 0L) {
size += methods.getObjectSize();
for (int i = 0; i < nmethods; ++i) {
Method m = (Method) methods.getObjAt(i);
size += m.getObjectSize();
size += objectSize(m.getConstMethod());
}
}
// MethodOrdering - an int array that records the original
// ordering of methods in the class file
size += arraySize(k.getMethodOrdering());
return size;
}
I think it worth doing part two about this.
REFs