Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/tools/PermStat.java @ 4061:e3e363b2bf19
7108242: jinfo -permstat shouldn't report interned strings as part of perm
Reviewed-by: kvn, twisti
author | never |
---|---|
date | Tue, 08 Nov 2011 20:42:26 -0800 |
parents | c18cbe5936b8 |
children | da91efe96a93 |
comparison
equal
deleted
inserted
replaced
4060:c9a03402fe56 | 4061:e3e363b2bf19 |
---|---|
61 long classSize; | 61 long classSize; |
62 List classDetail = new ArrayList(); // List<ClassData> | 62 List classDetail = new ArrayList(); // List<ClassData> |
63 } | 63 } |
64 | 64 |
65 public void run() { | 65 public void run() { |
66 printInternStringStatistics(); | |
67 printClassLoaderStatistics(); | 66 printClassLoaderStatistics(); |
68 } | |
69 | |
70 private void printInternStringStatistics() { | |
71 class StringStat implements StringTable.StringVisitor { | |
72 private int count; | |
73 private long size; | |
74 private OopField stringValueField; | |
75 | |
76 StringStat() { | |
77 VM vm = VM.getVM(); | |
78 SystemDictionary sysDict = vm.getSystemDictionary(); | |
79 InstanceKlass strKlass = sysDict.getStringKlass(); | |
80 // String has a field named 'value' of type 'char[]'. | |
81 stringValueField = (OopField) strKlass.findField("value", "[C"); | |
82 } | |
83 | |
84 private long stringSize(Instance instance) { | |
85 // We include String content in size calculation. | |
86 return instance.getObjectSize() + | |
87 stringValueField.getValue(instance).getObjectSize(); | |
88 } | |
89 | |
90 public void visit(Instance str) { | |
91 count++; | |
92 size += stringSize(str); | |
93 } | |
94 | |
95 public void print() { | |
96 System.out.println(count + | |
97 " intern Strings occupying " + size + " bytes."); | |
98 } | |
99 } | |
100 | |
101 StringStat stat = new StringStat(); | |
102 StringTable strTable = VM.getVM().getStringTable(); | |
103 strTable.stringsDo(stat); | |
104 stat.print(); | |
105 } | 67 } |
106 | 68 |
107 private void printClassLoaderStatistics() { | 69 private void printClassLoaderStatistics() { |
108 final PrintStream out = System.out; | 70 final PrintStream out = System.out; |
109 final PrintStream err = System.err; | 71 final PrintStream err = System.err; |