annotate agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java @ 12226:7944aba7ba41

8015107: NPG: Use consistent naming for metaspace concepts Reviewed-by: coleenp, mgerdin, hseigel
author ehelin
date Mon, 12 Aug 2013 17:37:02 +0200
parents 38ea2efa32a7
children 7fe6ef09d242
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
4830
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.tools;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.gc_interface.*;
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
29 import sun.jvm.hotspot.gc_implementation.g1.*;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.gc_implementation.shared.*;
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8114
diff changeset
32 import sun.jvm.hotspot.debugger.JVMDebugger;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.memory.*;
4061
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
34 import sun.jvm.hotspot.oops.*;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public class HeapSummary extends Tool {
a61af66fc99e Initial load
duke
parents:
diff changeset
38
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8114
diff changeset
39 public HeapSummary() {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8114
diff changeset
40 super();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8114
diff changeset
41 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8114
diff changeset
42
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8114
diff changeset
43 public HeapSummary(JVMDebugger d) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8114
diff changeset
44 super(d);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8114
diff changeset
45 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8114
diff changeset
46
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47 public static void main(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 HeapSummary hs = new HeapSummary();
a61af66fc99e Initial load
duke
parents:
diff changeset
49 hs.start(args);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 hs.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 CollectedHeap heap = VM.getVM().getUniverse().heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 VM.Flag[] flags = VM.getVM().getCommandLineFlags();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 Map flagMap = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
57 if (flags == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 System.out.println("WARNING: command line flags are not available");
a61af66fc99e Initial load
duke
parents:
diff changeset
59 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 for (int f = 0; f < flags.length; f++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 flagMap.put(flags[f].getName(), flags[f]);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 System.out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 printGCAlgorithm(flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 System.out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 System.out.println("Heap Configuration:");
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
69 printValue("MinHeapFreeRatio = ", getFlagValue("MinHeapFreeRatio", flagMap));
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
70 printValue("MaxHeapFreeRatio = ", getFlagValue("MaxHeapFreeRatio", flagMap));
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
71 printValMB("MaxHeapSize = ", getFlagValue("MaxHeapSize", flagMap));
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
72 printValMB("NewSize = ", getFlagValue("NewSize", flagMap));
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
73 printValMB("MaxNewSize = ", getFlagValue("MaxNewSize", flagMap));
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
74 printValMB("OldSize = ", getFlagValue("OldSize", flagMap));
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
75 printValue("NewRatio = ", getFlagValue("NewRatio", flagMap));
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
76 printValue("SurvivorRatio = ", getFlagValue("SurvivorRatio", flagMap));
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
77 printValMB("MetaspaceSize = ", getFlagValue("MetaspaceSize", flagMap));
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
78 printValMB("CompressedClassSpaceSize = ", getFlagValue("CompressedClassSpaceSize", flagMap));
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
79 printValMB("MaxMetaspaceSize = ", getFlagValue("MaxMetaspaceSize", flagMap));
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 11054
diff changeset
80 printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 System.out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 System.out.println("Heap Usage:");
a61af66fc99e Initial load
duke
parents:
diff changeset
84
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
85 if (heap instanceof SharedHeap) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
86 SharedHeap sharedHeap = (SharedHeap) heap;
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
87 if (sharedHeap instanceof GenCollectedHeap) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
88 GenCollectedHeap genHeap = (GenCollectedHeap) sharedHeap;
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
89 for (int n = 0; n < genHeap.nGens(); n++) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
90 Generation gen = genHeap.getGen(n);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
91 if (gen instanceof sun.jvm.hotspot.memory.DefNewGeneration) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
92 System.out.println("New Generation (Eden + 1 Survivor Space):");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
93 printGen(gen);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
94
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
95 ContiguousSpace eden = ((DefNewGeneration)gen).eden();
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
96 System.out.println("Eden Space:");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
97 printSpace(eden);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
98
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
99 ContiguousSpace from = ((DefNewGeneration)gen).from();
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
100 System.out.println("From Space:");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
101 printSpace(from);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
103 ContiguousSpace to = ((DefNewGeneration)gen).to();
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
104 System.out.println("To Space:");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
105 printSpace(to);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
106 } else {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
107 System.out.println(gen.name() + ":");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
108 printGen(gen);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
109 }
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
110 }
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
111 } else if (sharedHeap instanceof G1CollectedHeap) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
112 G1CollectedHeap g1h = (G1CollectedHeap) sharedHeap;
3984
81aa07130d30 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 3972
diff changeset
113 G1MonitoringSupport g1mm = g1h.g1mm();
4830
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
114 long edenRegionNum = g1mm.edenRegionNum();
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
115 long survivorRegionNum = g1mm.survivorRegionNum();
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
116 HeapRegionSetBase oldSet = g1h.oldSet();
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
117 HeapRegionSetBase humongousSet = g1h.humongousSet();
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
118 long oldRegionNum = oldSet.regionNum() + humongousSet.regionNum();
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
119 printG1Space("G1 Heap:", g1h.n_regions(),
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
120 g1h.used(), g1h.capacity());
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
121 System.out.println("G1 Young Generation:");
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
122 printG1Space("Eden Space:", edenRegionNum,
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
123 g1mm.edenUsed(), g1mm.edenCommitted());
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
124 printG1Space("Survivor Space:", survivorRegionNum,
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
125 g1mm.survivorUsed(), g1mm.survivorCommitted());
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
126 printG1Space("G1 Old Generation:", oldRegionNum,
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
127 g1mm.oldUsed(), g1mm.oldCommitted());
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
128 } else {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
129 throw new RuntimeException("unknown SharedHeap type : " + heap.getClass());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 } else if (heap instanceof ParallelScavengeHeap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 PSYoungGen youngGen = psh.youngGen();
a61af66fc99e Initial load
duke
parents:
diff changeset
134 printPSYoungGen(youngGen);
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 PSOldGen oldGen = psh.oldGen();
a61af66fc99e Initial load
duke
parents:
diff changeset
137 long oldFree = oldGen.capacity() - oldGen.used();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 System.out.println("PS Old Generation");
a61af66fc99e Initial load
duke
parents:
diff changeset
139 printValMB("capacity = ", oldGen.capacity());
a61af66fc99e Initial load
duke
parents:
diff changeset
140 printValMB("used = ", oldGen.used());
a61af66fc99e Initial load
duke
parents:
diff changeset
141 printValMB("free = ", oldFree);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 System.out.println(alignment + (double)oldGen.used() * 100.0 / oldGen.capacity() + "% used");
a61af66fc99e Initial load
duke
parents:
diff changeset
143 } else {
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
144 throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
4061
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
146
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
147 System.out.println();
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
148 printInternStringStatistics();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Helper methods
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 private void printGCAlgorithm(Map flagMap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // print about new generation
a61af66fc99e Initial load
duke
parents:
diff changeset
155 long l = getFlagValue("UseParNewGC", flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 if (l == 1L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 System.out.println("using parallel threads in the new generation.");
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 l = getFlagValue("UseTLAB", flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 if (l == 1L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 System.out.println("using thread-local object allocation.");
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 l = getFlagValue("UseConcMarkSweepGC", flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 if (l == 1L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 System.out.println("Concurrent Mark-Sweep GC");
a61af66fc99e Initial load
duke
parents:
diff changeset
168 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 l = getFlagValue("UseParallelGC", flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if (l == 1L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 System.out.print("Parallel GC ");
a61af66fc99e Initial load
duke
parents:
diff changeset
174 l = getFlagValue("ParallelGCThreads", flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
175 System.out.println("with " + l + " thread(s)");
a61af66fc99e Initial load
duke
parents:
diff changeset
176 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
179 l = getFlagValue("UseG1GC", flagMap);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
180 if (l == 1L) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
181 System.out.print("Garbage-First (G1) GC ");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
182 l = getFlagValue("ParallelGCThreads", flagMap);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
183 System.out.println("with " + l + " thread(s)");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
184 return;
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
185 }
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
186
0
a61af66fc99e Initial load
duke
parents:
diff changeset
187 System.out.println("Mark Sweep Compact GC");
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 private void printPSYoungGen(PSYoungGen youngGen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 System.out.println("PS Young Generation");
a61af66fc99e Initial load
duke
parents:
diff changeset
192 MutableSpace eden = youngGen.edenSpace();
a61af66fc99e Initial load
duke
parents:
diff changeset
193 System.out.println("Eden Space:");
a61af66fc99e Initial load
duke
parents:
diff changeset
194 printMutableSpace(eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 MutableSpace from = youngGen.fromSpace();
a61af66fc99e Initial load
duke
parents:
diff changeset
196 System.out.println("From Space:");
a61af66fc99e Initial load
duke
parents:
diff changeset
197 printMutableSpace(from);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 MutableSpace to = youngGen.toSpace();
a61af66fc99e Initial load
duke
parents:
diff changeset
199 System.out.println("To Space:");
a61af66fc99e Initial load
duke
parents:
diff changeset
200 printMutableSpace(to);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 private void printMutableSpace(MutableSpace space) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 printValMB("capacity = ", space.capacity());
a61af66fc99e Initial load
duke
parents:
diff changeset
205 printValMB("used = ", space.used());
a61af66fc99e Initial load
duke
parents:
diff changeset
206 long free = space.capacity() - space.used();
a61af66fc99e Initial load
duke
parents:
diff changeset
207 printValMB("free = ", free);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 System.out.println(alignment + (double)space.used() * 100.0 / space.capacity() + "% used");
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 private static String alignment = " ";
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 private void printGen(Generation gen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 printValMB("capacity = ", gen.capacity());
a61af66fc99e Initial load
duke
parents:
diff changeset
215 printValMB("used = ", gen.used());
a61af66fc99e Initial load
duke
parents:
diff changeset
216 printValMB("free = ", gen.free());
a61af66fc99e Initial load
duke
parents:
diff changeset
217 System.out.println(alignment + (double)gen.used() * 100.0 / gen.capacity() + "% used");
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 private void printSpace(ContiguousSpace space) {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 printValMB("capacity = ", space.capacity());
a61af66fc99e Initial load
duke
parents:
diff changeset
222 printValMB("used = ", space.used());
a61af66fc99e Initial load
duke
parents:
diff changeset
223 printValMB("free = ", space.free());
a61af66fc99e Initial load
duke
parents:
diff changeset
224 System.out.println(alignment + (double)space.used() * 100.0 / space.capacity() + "% used");
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226
4830
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
227 private void printG1Space(String spaceName, long regionNum,
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
228 long used, long capacity) {
3984
81aa07130d30 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 3972
diff changeset
229 long free = capacity - used;
81aa07130d30 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 3972
diff changeset
230 System.out.println(spaceName);
4830
0b3d1ec6eaee 7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents: 4061
diff changeset
231 printValue("regions = ", regionNum);
3984
81aa07130d30 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 3972
diff changeset
232 printValMB("capacity = ", capacity);
81aa07130d30 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 3972
diff changeset
233 printValMB("used = ", used);
81aa07130d30 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 3972
diff changeset
234 printValMB("free = ", free);
81aa07130d30 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 3972
diff changeset
235 double occPerc = (capacity > 0) ? (double) used * 100.0 / capacity : 0.0;
81aa07130d30 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 3972
diff changeset
236 System.out.println(alignment + occPerc + "% used");
81aa07130d30 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 3972
diff changeset
237 }
81aa07130d30 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 3972
diff changeset
238
0
a61af66fc99e Initial load
duke
parents:
diff changeset
239 private static final double FACTOR = 1024*1024;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 private void printValMB(String title, long value) {
281
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
241 if (value < 0) {
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
242 System.out.println(alignment + title + (value >>> 20) + " MB");
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
243 } else {
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
244 double mb = value/FACTOR;
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
245 System.out.println(alignment + title + value + " (" + mb + "MB)");
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
246 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 private void printValue(String title, long value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 System.out.println(alignment + title + value);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 private long getFlagValue(String name, Map flagMap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 VM.Flag f = (VM.Flag) flagMap.get(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 if (f != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 if (f.isBool()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 return f.getBool()? 1L : 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 return Long.parseLong(f.getValue());
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
4061
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
265
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
266 private void printInternStringStatistics() {
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
267 class StringStat implements StringTable.StringVisitor {
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
268 private int count;
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
269 private long size;
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
270 private OopField stringValueField;
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
271
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
272 StringStat() {
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
273 VM vm = VM.getVM();
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
274 SystemDictionary sysDict = vm.getSystemDictionary();
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
275 InstanceKlass strKlass = sysDict.getStringKlass();
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
276 // String has a field named 'value' of type 'char[]'.
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
277 stringValueField = (OopField) strKlass.findField("value", "[C");
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
278 }
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
279
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
280 private long stringSize(Instance instance) {
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
281 // We include String content in size calculation.
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
282 return instance.getObjectSize() +
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
283 stringValueField.getValue(instance).getObjectSize();
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
284 }
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
285
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
286 public void visit(Instance str) {
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
287 count++;
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
288 size += stringSize(str);
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
289 }
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
290
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
291 public void print() {
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
292 System.out.println(count +
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
293 " interned Strings occupying " + size + " bytes.");
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
294 }
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
295 }
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
296
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
297 StringStat stat = new StringStat();
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
298 StringTable strTable = VM.getVM().getStringTable();
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
299 strTable.stringsDo(stat);
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
300 stat.print();
e3e363b2bf19 7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents: 3984
diff changeset
301 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }