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

Thu, 31 Jul 2008 18:50:37 -0700

author
martin
date
Thu, 31 Jul 2008 18:50:37 -0700
changeset 696
7f601f7c9b48
parent 694
c7e8144ef65e
child 697
f31ba9518910

6731726: jmap -permstat reports only 50-60% of permgen memory usage.
Reviewed-by: swamyv, martin
Contributed-by: yamauchi@google.com

agent/src/share/classes/sun/jvm/hotspot/tools/PermStat.java file | annotate | diff | comparison | revisions
     1.1 --- a/agent/src/share/classes/sun/jvm/hotspot/tools/PermStat.java	Wed Jul 30 14:41:55 2008 -0700
     1.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/PermStat.java	Thu Jul 31 18:50:37 2008 -0700
     1.3 @@ -266,45 +266,51 @@
     1.4        out.println();
     1.5     }
     1.6  
     1.7 +   private static long objectSize(Oop oop) {
     1.8 +      return oop == null ? 0L : oop.getObjectSize();
     1.9 +   }
    1.10 +
    1.11 +   // Don't count the shared empty arrays
    1.12 +   private static long arraySize(Array arr) {
    1.13 +     return arr.getLength() != 0L ? arr.getObjectSize() : 0L;
    1.14 +   }
    1.15 +
    1.16     private long computeSize(InstanceKlass k) {
    1.17        long size = 0L;
    1.18 -      // InstanceKlass object size
    1.19 +      // the InstanceKlass object itself
    1.20        size += k.getObjectSize();
    1.21  
    1.22 -      // add ConstantPool size
    1.23 -      size += k.getConstants().getObjectSize();
    1.24 +      // Constant pool
    1.25 +      ConstantPool cp = k.getConstants();
    1.26 +      size += cp.getObjectSize();
    1.27 +      size += objectSize(cp.getCache());
    1.28 +      size += objectSize(cp.getTags());
    1.29  
    1.30 -      // add ConstantPoolCache, if any
    1.31 -      ConstantPoolCache cpCache = k.getConstants().getCache();
    1.32 -      if (cpCache != null) {
    1.33 -         size += cpCache.getObjectSize();
    1.34 +      // Interfaces
    1.35 +      size += arraySize(k.getLocalInterfaces());
    1.36 +      size += arraySize(k.getTransitiveInterfaces());
    1.37 +
    1.38 +      // Inner classes
    1.39 +      size += objectSize(k.getInnerClasses());
    1.40 +
    1.41 +      // Fields
    1.42 +      size += objectSize(k.getFields());
    1.43 +
    1.44 +      // Methods
    1.45 +      ObjArray methods = k.getMethods();
    1.46 +      int nmethods = (int) methods.getLength();
    1.47 +      if (nmethods != 0L) {
    1.48 +         size += methods.getObjectSize();
    1.49 +         for (int i = 0; i < nmethods; ++i) {
    1.50 +            Method m = (Method) methods.getObjAt(i);
    1.51 +            size += m.getObjectSize();
    1.52 +            size += objectSize(m.getConstMethod());
    1.53 +         }
    1.54        }
    1.55  
    1.56 -      // add interfaces size
    1.57 -      ObjArray interfaces = k.getLocalInterfaces();
    1.58 -      size +=  (interfaces.getLength() != 0L)? interfaces.getObjectSize() : 0L;
    1.59 -      ObjArray transitiveInterfaces = k.getTransitiveInterfaces();
    1.60 -      size += (transitiveInterfaces.getLength() != 0L)? transitiveInterfaces.getObjectSize() : 0L;
    1.61 -
    1.62 -      // add inner classes size
    1.63 -      TypeArray innerClasses = k.getInnerClasses();
    1.64 -      size += innerClasses.getObjectSize();
    1.65 -
    1.66 -      // add fields size
    1.67 -      size += k.getFields().getObjectSize();
    1.68 -
    1.69 -      // add methods size
    1.70 -      ObjArray methods = k.getMethods();
    1.71 -      size += (methods.getLength() != 0L)? methods.getObjectSize() : 0L;
    1.72 -      TypeArray methodOrdering = k.getMethodOrdering();
    1.73 -      size += (methodOrdering.getLength() != 0L)? methodOrdering.getObjectSize() : 0;
    1.74 -
    1.75 -      // add each method's size
    1.76 -      int numMethods = (int) methods.getLength();
    1.77 -      for (int i = 0; i < numMethods; i++) {
    1.78 -         Method m = (Method) methods.getObjAt(i);
    1.79 -         size += m.getObjectSize();
    1.80 -      }
    1.81 +      // MethodOrdering - an int array that records the original
    1.82 +      // ordering of methods in the class file
    1.83 +      size += arraySize(k.getMethodOrdering());
    1.84  
    1.85        return size;
    1.86     }

mercurial