提交 87a46b4e 编写于 作者: M martin

6731726: jmap -permstat reports only 50-60% of permgen memory usage.

Reviewed-by: swamyv, martin
Contributed-by: yamauchi@google.com
上级 274b6a88
...@@ -266,46 +266,52 @@ public class PermStat extends Tool { ...@@ -266,46 +266,52 @@ public class PermStat extends Tool {
out.println(); out.println();
} }
private static long objectSize(Oop oop) {
return oop == null ? 0L : oop.getObjectSize();
}
// Don't count the shared empty arrays
private static long arraySize(Array arr) {
return arr.getLength() != 0L ? arr.getObjectSize() : 0L;
}
private long computeSize(InstanceKlass k) { private long computeSize(InstanceKlass k) {
long size = 0L; long size = 0L;
// InstanceKlass object size // the InstanceKlass object itself
size += k.getObjectSize(); size += k.getObjectSize();
// add ConstantPool size // Constant pool
size += k.getConstants().getObjectSize(); ConstantPool cp = k.getConstants();
size += cp.getObjectSize();
size += objectSize(cp.getCache());
size += objectSize(cp.getTags());
// add ConstantPoolCache, if any // Interfaces
ConstantPoolCache cpCache = k.getConstants().getCache(); size += arraySize(k.getLocalInterfaces());
if (cpCache != null) { size += arraySize(k.getTransitiveInterfaces());
size += cpCache.getObjectSize();
}
// add interfaces size
ObjArray interfaces = k.getLocalInterfaces();
size += (interfaces.getLength() != 0L)? interfaces.getObjectSize() : 0L;
ObjArray transitiveInterfaces = k.getTransitiveInterfaces();
size += (transitiveInterfaces.getLength() != 0L)? transitiveInterfaces.getObjectSize() : 0L;
// add inner classes size // Inner classes
TypeArray innerClasses = k.getInnerClasses(); size += objectSize(k.getInnerClasses());
size += innerClasses.getObjectSize();
// add fields size // Fields
size += k.getFields().getObjectSize(); size += objectSize(k.getFields());
// add methods size // Methods
ObjArray methods = k.getMethods(); ObjArray methods = k.getMethods();
size += (methods.getLength() != 0L)? methods.getObjectSize() : 0L; int nmethods = (int) methods.getLength();
TypeArray methodOrdering = k.getMethodOrdering(); if (nmethods != 0L) {
size += (methodOrdering.getLength() != 0L)? methodOrdering.getObjectSize() : 0; size += methods.getObjectSize();
for (int i = 0; i < nmethods; ++i) {
// add each method's size Method m = (Method) methods.getObjAt(i);
int numMethods = (int) methods.getLength(); size += m.getObjectSize();
for (int i = 0; i < numMethods; i++) { size += objectSize(m.getConstMethod());
Method m = (Method) methods.getObjAt(i); }
size += m.getObjectSize();
} }
// MethodOrdering - an int array that records the original
// ordering of methods in the class file
size += arraySize(k.getMethodOrdering());
return size; return size;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册