112 }
113 } else if (heap instanceof G1CollectedHeap) {
114 printG1HeapSummary((G1CollectedHeap)heap);
115 } else if (heap instanceof ParallelScavengeHeap) {
116 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
117 PSYoungGen youngGen = psh.youngGen();
118 printPSYoungGen(youngGen);
119
120 PSOldGen oldGen = psh.oldGen();
121 long oldFree = oldGen.capacity() - oldGen.used();
122 System.out.println("PS Old Generation");
123 printValMB("capacity = ", oldGen.capacity());
124 printValMB("used = ", oldGen.used());
125 printValMB("free = ", oldFree);
126 System.out.println(alignment + (double)oldGen.used() * 100.0 / oldGen.capacity() + "% used");
127 } else {
128 throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass());
129 }
130
131 System.out.println();
132 printInternStringStatistics();
133 }
134
135 // Helper methods
136
137 private void printGCAlgorithm(Map flagMap) {
138 long l = getFlagValue("UseTLAB", flagMap);
139 if (l == 1L) {
140 System.out.println("using thread-local object allocation.");
141 }
142
143 l = getFlagValue("UseConcMarkSweepGC", flagMap);
144 if (l == 1L) {
145 System.out.println("Concurrent Mark-Sweep GC");
146 return;
147 }
148
149 l = getFlagValue("UseParallelGC", flagMap);
150 if (l == 1L) {
151 System.out.print("Parallel GC ");
152 l = getFlagValue("ParallelGCThreads", flagMap);
240 double mb = value/FACTOR;
241 System.out.println(alignment + title + value + " (" + mb + "MB)");
242 }
243 }
244
245 private void printValue(String title, long value) {
246 System.out.println(alignment + title + value);
247 }
248
249 private long getFlagValue(String name, Map flagMap) {
250 VM.Flag f = (VM.Flag) flagMap.get(name);
251 if (f != null) {
252 if (f.isBool()) {
253 return f.getBool()? 1L : 0L;
254 } else {
255 return Long.parseLong(f.getValue());
256 }
257 } else {
258 return -1;
259 }
260 }
261
262 private void printInternStringStatistics() {
263 class StringStat implements StringTable.StringVisitor {
264 private int count;
265 private long size;
266 private OopField stringValueField;
267
268 StringStat() {
269 VM vm = VM.getVM();
270 SystemDictionary sysDict = vm.getSystemDictionary();
271 InstanceKlass strKlass = sysDict.getStringKlass();
272 // String has a field named 'value' of type 'byte[]'.
273 stringValueField = (OopField) strKlass.findField("value", "[B");
274 }
275
276 private long stringSize(Instance instance) {
277 // We include String content in size calculation.
278 return instance.getObjectSize() +
279 stringValueField.getValue(instance).getObjectSize();
280 }
281
282 public void visit(Instance str) {
283 count++;
284 size += stringSize(str);
285 }
286
287 public void print() {
288 System.out.println(count +
289 " interned Strings occupying " + size + " bytes.");
290 }
291 }
292
293 StringStat stat = new StringStat();
294 StringTable strTable = VM.getVM().getStringTable();
295 strTable.stringsDo(stat);
296 stat.print();
297 }
298 }
|
112 }
113 } else if (heap instanceof G1CollectedHeap) {
114 printG1HeapSummary((G1CollectedHeap)heap);
115 } else if (heap instanceof ParallelScavengeHeap) {
116 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
117 PSYoungGen youngGen = psh.youngGen();
118 printPSYoungGen(youngGen);
119
120 PSOldGen oldGen = psh.oldGen();
121 long oldFree = oldGen.capacity() - oldGen.used();
122 System.out.println("PS Old Generation");
123 printValMB("capacity = ", oldGen.capacity());
124 printValMB("used = ", oldGen.used());
125 printValMB("free = ", oldFree);
126 System.out.println(alignment + (double)oldGen.used() * 100.0 / oldGen.capacity() + "% used");
127 } else {
128 throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass());
129 }
130
131 System.out.println();
132 }
133
134 // Helper methods
135
136 private void printGCAlgorithm(Map flagMap) {
137 long l = getFlagValue("UseTLAB", flagMap);
138 if (l == 1L) {
139 System.out.println("using thread-local object allocation.");
140 }
141
142 l = getFlagValue("UseConcMarkSweepGC", flagMap);
143 if (l == 1L) {
144 System.out.println("Concurrent Mark-Sweep GC");
145 return;
146 }
147
148 l = getFlagValue("UseParallelGC", flagMap);
149 if (l == 1L) {
150 System.out.print("Parallel GC ");
151 l = getFlagValue("ParallelGCThreads", flagMap);
239 double mb = value/FACTOR;
240 System.out.println(alignment + title + value + " (" + mb + "MB)");
241 }
242 }
243
244 private void printValue(String title, long value) {
245 System.out.println(alignment + title + value);
246 }
247
248 private long getFlagValue(String name, Map flagMap) {
249 VM.Flag f = (VM.Flag) flagMap.get(name);
250 if (f != null) {
251 if (f.isBool()) {
252 return f.getBool()? 1L : 0L;
253 } else {
254 return Long.parseLong(f.getValue());
255 }
256 } else {
257 return -1;
258 }
259 }
260 }
|