author | lkorinth |
Wed, 13 Nov 2019 11:37:29 +0100 | |
changeset 59053 | ba6c248cae19 |
parent 53517 | 20ba6a7f897a |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53517
20ba6a7f897a
8217850: CompressedClassSpaceSizeInJmapHeap fails after JDK-8217612
ysuenaga
parents:
52925
diff
changeset
|
2 |
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1217
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1217
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1217
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot.tools; |
|
26 |
||
27 |
import java.util.*; |
|
50523
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
50445
diff
changeset
|
28 |
import sun.jvm.hotspot.gc.epsilon.*; |
30764 | 29 |
import sun.jvm.hotspot.gc.g1.*; |
30 |
import sun.jvm.hotspot.gc.parallel.*; |
|
30769 | 31 |
import sun.jvm.hotspot.gc.serial.*; |
52925
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
32 |
import sun.jvm.hotspot.gc.shenandoah.*; |
30764 | 33 |
import sun.jvm.hotspot.gc.shared.*; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
34 |
import sun.jvm.hotspot.gc.z.*; |
18481
fa7f6ad24216
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
15811
diff
changeset
|
35 |
import sun.jvm.hotspot.debugger.JVMDebugger; |
1 | 36 |
import sun.jvm.hotspot.memory.*; |
10985
f529e2356036
7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents:
10675
diff
changeset
|
37 |
import sun.jvm.hotspot.oops.*; |
1 | 38 |
import sun.jvm.hotspot.runtime.*; |
39 |
||
38261
ddf6760621fc
8155091: Remove SA related functions from tmtools
dsamersoff
parents:
36508
diff
changeset
|
40 |
public class HeapSummary extends Tool { |
1 | 41 |
|
18481
fa7f6ad24216
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
15811
diff
changeset
|
42 |
public HeapSummary() { |
fa7f6ad24216
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
15811
diff
changeset
|
43 |
super(); |
fa7f6ad24216
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
15811
diff
changeset
|
44 |
} |
fa7f6ad24216
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
15811
diff
changeset
|
45 |
|
fa7f6ad24216
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
15811
diff
changeset
|
46 |
public HeapSummary(JVMDebugger d) { |
fa7f6ad24216
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
15811
diff
changeset
|
47 |
super(d); |
fa7f6ad24216
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
15811
diff
changeset
|
48 |
} |
fa7f6ad24216
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
15811
diff
changeset
|
49 |
|
1 | 50 |
public static void main(String[] args) { |
51 |
HeapSummary hs = new HeapSummary(); |
|
21065
b8281f54308b
8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents:
19979
diff
changeset
|
52 |
hs.execute(args); |
1 | 53 |
} |
54 |
||
36508 | 55 |
@Override |
56 |
public String getName() { |
|
57 |
return "heapSummary"; |
|
58 |
} |
|
59 |
||
1 | 60 |
public void run() { |
61 |
CollectedHeap heap = VM.getVM().getUniverse().heap(); |
|
62 |
VM.Flag[] flags = VM.getVM().getCommandLineFlags(); |
|
63 |
Map flagMap = new HashMap(); |
|
64 |
if (flags == null) { |
|
65 |
System.out.println("WARNING: command line flags are not available"); |
|
66 |
} else { |
|
67 |
for (int f = 0; f < flags.length; f++) { |
|
68 |
flagMap.put(flags[f].getName(), flags[f]); |
|
69 |
} |
|
70 |
} |
|
71 |
||
72 |
System.out.println(); |
|
73 |
printGCAlgorithm(flagMap); |
|
74 |
System.out.println(); |
|
75 |
System.out.println("Heap Configuration:"); |
|
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
18481
diff
changeset
|
76 |
printValue("MinHeapFreeRatio = ", getFlagValue("MinHeapFreeRatio", flagMap)); |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
18481
diff
changeset
|
77 |
printValue("MaxHeapFreeRatio = ", getFlagValue("MaxHeapFreeRatio", flagMap)); |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
18481
diff
changeset
|
78 |
printValMB("MaxHeapSize = ", getFlagValue("MaxHeapSize", flagMap)); |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
18481
diff
changeset
|
79 |
printValMB("NewSize = ", getFlagValue("NewSize", flagMap)); |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
18481
diff
changeset
|
80 |
printValMB("MaxNewSize = ", getFlagValue("MaxNewSize", flagMap)); |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
18481
diff
changeset
|
81 |
printValMB("OldSize = ", getFlagValue("OldSize", flagMap)); |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
18481
diff
changeset
|
82 |
printValue("NewRatio = ", getFlagValue("NewRatio", flagMap)); |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
18481
diff
changeset
|
83 |
printValue("SurvivorRatio = ", getFlagValue("SurvivorRatio", flagMap)); |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
18481
diff
changeset
|
84 |
printValMB("MetaspaceSize = ", getFlagValue("MetaspaceSize", flagMap)); |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
18481
diff
changeset
|
85 |
printValMB("CompressedClassSpaceSize = ", getFlagValue("CompressedClassSpaceSize", flagMap)); |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
18481
diff
changeset
|
86 |
printValMB("MaxMetaspaceSize = ", getFlagValue("MaxMetaspaceSize", flagMap)); |
52925
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
87 |
if (heap instanceof ShenandoahHeap) { |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
88 |
printValMB("ShenandoahRegionSize = ", ShenandoahHeapRegion.regionSizeBytes()); |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
89 |
} else { |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
90 |
printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes()); |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
91 |
} |
1 | 92 |
|
93 |
System.out.println(); |
|
94 |
System.out.println("Heap Usage:"); |
|
95 |
||
30154 | 96 |
if (heap instanceof GenCollectedHeap) { |
97 |
GenCollectedHeap genHeap = (GenCollectedHeap) heap; |
|
98 |
for (int n = 0; n < genHeap.nGens(); n++) { |
|
99 |
Generation gen = genHeap.getGen(n); |
|
30769 | 100 |
if (gen instanceof DefNewGeneration) { |
30154 | 101 |
System.out.println("New Generation (Eden + 1 Survivor Space):"); |
102 |
printGen(gen); |
|
1 | 103 |
|
30154 | 104 |
ContiguousSpace eden = ((DefNewGeneration)gen).eden(); |
105 |
System.out.println("Eden Space:"); |
|
106 |
printSpace(eden); |
|
10663 | 107 |
|
30154 | 108 |
ContiguousSpace from = ((DefNewGeneration)gen).from(); |
109 |
System.out.println("From Space:"); |
|
110 |
printSpace(from); |
|
1 | 111 |
|
30154 | 112 |
ContiguousSpace to = ((DefNewGeneration)gen).to(); |
113 |
System.out.println("To Space:"); |
|
114 |
printSpace(to); |
|
115 |
} else { |
|
116 |
System.out.println(gen.name() + ":"); |
|
117 |
printGen(gen); |
|
10663 | 118 |
} |
1 | 119 |
} |
30154 | 120 |
} else if (heap instanceof G1CollectedHeap) { |
49463
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47216
diff
changeset
|
121 |
printG1HeapSummary((G1CollectedHeap)heap); |
1 | 122 |
} else if (heap instanceof ParallelScavengeHeap) { |
123 |
ParallelScavengeHeap psh = (ParallelScavengeHeap) heap; |
|
124 |
PSYoungGen youngGen = psh.youngGen(); |
|
125 |
printPSYoungGen(youngGen); |
|
126 |
||
127 |
PSOldGen oldGen = psh.oldGen(); |
|
128 |
long oldFree = oldGen.capacity() - oldGen.used(); |
|
129 |
System.out.println("PS Old Generation"); |
|
130 |
printValMB("capacity = ", oldGen.capacity()); |
|
131 |
printValMB("used = ", oldGen.used()); |
|
132 |
printValMB("free = ", oldFree); |
|
133 |
System.out.println(alignment + (double)oldGen.used() * 100.0 / oldGen.capacity() + "% used"); |
|
52925
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
134 |
} else if (heap instanceof ShenandoahHeap) { |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
135 |
ShenandoahHeap sh = (ShenandoahHeap) heap; |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
136 |
long num_regions = sh.numOfRegions(); |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
137 |
System.out.println("Shenandoah Heap:"); |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
138 |
System.out.println(" regions = " + num_regions); |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
139 |
printValMB("capacity = ", num_regions * ShenandoahHeapRegion.regionSizeBytes()); |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
140 |
printValMB("used = ", sh.used()); |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
141 |
printValMB("committed = ", sh.committed()); |
50523
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
50445
diff
changeset
|
142 |
} else if (heap instanceof EpsilonHeap) { |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
50445
diff
changeset
|
143 |
EpsilonHeap eh = (EpsilonHeap) heap; |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
50445
diff
changeset
|
144 |
printSpace(eh.space()); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
145 |
} else if (heap instanceof ZCollectedHeap) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
146 |
ZCollectedHeap zheap = (ZCollectedHeap) heap; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
147 |
zheap.printOn(System.out); |
1 | 148 |
} else { |
10663 | 149 |
throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass()); |
1 | 150 |
} |
10985
f529e2356036
7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents:
10675
diff
changeset
|
151 |
|
f529e2356036
7108242: jinfo -permstat shouldn't report interned strings as part of perm
never
parents:
10675
diff
changeset
|
152 |
System.out.println(); |
1 | 153 |
} |
154 |
||
155 |
// Helper methods |
|
156 |
||
157 |
private void printGCAlgorithm(Map flagMap) { |
|
43605
07baf498d588
8173421: Obsolete and expired flags for JDK 10 need to be removed and related tests updated
dholmes
parents:
38261
diff
changeset
|
158 |
long l = getFlagValue("UseTLAB", flagMap); |
1 | 159 |
if (l == 1L) { |
160 |
System.out.println("using thread-local object allocation."); |
|
161 |
} |
|
162 |
||
163 |
l = getFlagValue("UseParallelGC", flagMap); |
|
164 |
if (l == 1L) { |
|
165 |
System.out.print("Parallel GC "); |
|
166 |
l = getFlagValue("ParallelGCThreads", flagMap); |
|
167 |
System.out.println("with " + l + " thread(s)"); |
|
168 |
return; |
|
169 |
} |
|
170 |
||
10663 | 171 |
l = getFlagValue("UseG1GC", flagMap); |
172 |
if (l == 1L) { |
|
173 |
System.out.print("Garbage-First (G1) GC "); |
|
174 |
l = getFlagValue("ParallelGCThreads", flagMap); |
|
175 |
System.out.println("with " + l + " thread(s)"); |
|
176 |
return; |
|
177 |
} |
|
178 |
||
50523
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
50445
diff
changeset
|
179 |
l = getFlagValue("UseEpsilonGC", flagMap); |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
50445
diff
changeset
|
180 |
if (l == 1L) { |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
50445
diff
changeset
|
181 |
System.out.println("Epsilon (no-op) GC"); |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
50445
diff
changeset
|
182 |
return; |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
50445
diff
changeset
|
183 |
} |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
50445
diff
changeset
|
184 |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
185 |
l = getFlagValue("UseZGC", flagMap); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
186 |
if (l == 1L) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
187 |
System.out.print("ZGC "); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
188 |
l = getFlagValue("ParallelGCThreads", flagMap); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
189 |
System.out.println("with " + l + " thread(s)"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
190 |
return; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
191 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
192 |
|
52925
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
193 |
l = getFlagValue("UseShenandoahGC", flagMap); |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
194 |
if (l == 1L) { |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
195 |
System.out.print("Shenandoah GC "); |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
196 |
l = getFlagValue("ParallelGCThreads", flagMap); |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
197 |
System.out.println("with " + l + " thread(s)"); |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
198 |
return; |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
199 |
} |
9c18c9d839d3
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
51498
diff
changeset
|
200 |
|
1 | 201 |
System.out.println("Mark Sweep Compact GC"); |
202 |
} |
|
203 |
||
204 |
private void printPSYoungGen(PSYoungGen youngGen) { |
|
205 |
System.out.println("PS Young Generation"); |
|
206 |
MutableSpace eden = youngGen.edenSpace(); |
|
207 |
System.out.println("Eden Space:"); |
|
208 |
printMutableSpace(eden); |
|
209 |
MutableSpace from = youngGen.fromSpace(); |
|
210 |
System.out.println("From Space:"); |
|
211 |
printMutableSpace(from); |
|
212 |
MutableSpace to = youngGen.toSpace(); |
|
213 |
System.out.println("To Space:"); |
|
214 |
printMutableSpace(to); |
|
215 |
} |
|
216 |
||
217 |
private void printMutableSpace(MutableSpace space) { |
|
218 |
printValMB("capacity = ", space.capacity()); |
|
219 |
printValMB("used = ", space.used()); |
|
220 |
long free = space.capacity() - space.used(); |
|
221 |
printValMB("free = ", free); |
|
222 |
System.out.println(alignment + (double)space.used() * 100.0 / space.capacity() + "% used"); |
|
223 |
} |
|
224 |
||
225 |
private static String alignment = " "; |
|
226 |
||
227 |
private void printGen(Generation gen) { |
|
228 |
printValMB("capacity = ", gen.capacity()); |
|
229 |
printValMB("used = ", gen.used()); |
|
230 |
printValMB("free = ", gen.free()); |
|
231 |
System.out.println(alignment + (double)gen.used() * 100.0 / gen.capacity() + "% used"); |
|
232 |
} |
|
233 |
||
234 |
private void printSpace(ContiguousSpace space) { |
|
235 |
printValMB("capacity = ", space.capacity()); |
|
236 |
printValMB("used = ", space.used()); |
|
237 |
printValMB("free = ", space.free()); |
|
238 |
System.out.println(alignment + (double)space.used() * 100.0 / space.capacity() + "% used"); |
|
239 |
} |
|
240 |
||
49463
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47216
diff
changeset
|
241 |
public void printG1HeapSummary(G1CollectedHeap g1h) { |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47216
diff
changeset
|
242 |
G1MonitoringSupport g1mm = g1h.g1mm(); |
51498 | 243 |
long edenSpaceRegionNum = g1mm.edenSpaceRegionNum(); |
244 |
long survivorSpaceRegionNum = g1mm.survivorSpaceRegionNum(); |
|
49463
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47216
diff
changeset
|
245 |
HeapRegionSetBase oldSet = g1h.oldSet(); |
51494
1906adbef2dc
8208498: Put archive regions into a first-class HeapRegionSet
tschatzl
parents:
50525
diff
changeset
|
246 |
HeapRegionSetBase archiveSet = g1h.archiveSet(); |
49463
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47216
diff
changeset
|
247 |
HeapRegionSetBase humongousSet = g1h.humongousSet(); |
51498 | 248 |
long oldGenRegionNum = oldSet.length() + archiveSet.length() + humongousSet.length(); |
49463
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47216
diff
changeset
|
249 |
printG1Space("G1 Heap:", g1h.n_regions(), |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47216
diff
changeset
|
250 |
g1h.used(), g1h.capacity()); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47216
diff
changeset
|
251 |
System.out.println("G1 Young Generation:"); |
51498 | 252 |
printG1Space("Eden Space:", edenSpaceRegionNum, |
253 |
g1mm.edenSpaceUsed(), g1mm.edenSpaceCommitted()); |
|
254 |
printG1Space("Survivor Space:", survivorSpaceRegionNum, |
|
255 |
g1mm.survivorSpaceUsed(), g1mm.survivorSpaceCommitted()); |
|
256 |
printG1Space("G1 Old Generation:", oldGenRegionNum, |
|
257 |
g1mm.oldGenUsed(), g1mm.oldGenCommitted()); |
|
49463
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47216
diff
changeset
|
258 |
} |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47216
diff
changeset
|
259 |
|
11577
0af7e6e062a7
7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents:
10985
diff
changeset
|
260 |
private void printG1Space(String spaceName, long regionNum, |
0af7e6e062a7
7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents:
10985
diff
changeset
|
261 |
long used, long capacity) { |
10675
8b887b2cb116
7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents:
10663
diff
changeset
|
262 |
long free = capacity - used; |
8b887b2cb116
7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents:
10663
diff
changeset
|
263 |
System.out.println(spaceName); |
11577
0af7e6e062a7
7097586: G1: improve the per-space output when using jmap -heap
tonyp
parents:
10985
diff
changeset
|
264 |
printValue("regions = ", regionNum); |
10675
8b887b2cb116
7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents:
10663
diff
changeset
|
265 |
printValMB("capacity = ", capacity); |
8b887b2cb116
7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents:
10663
diff
changeset
|
266 |
printValMB("used = ", used); |
8b887b2cb116
7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents:
10663
diff
changeset
|
267 |
printValMB("free = ", free); |
8b887b2cb116
7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents:
10663
diff
changeset
|
268 |
double occPerc = (capacity > 0) ? (double) used * 100.0 / capacity : 0.0; |
8b887b2cb116
7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents:
10663
diff
changeset
|
269 |
System.out.println(alignment + occPerc + "% used"); |
8b887b2cb116
7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents:
10663
diff
changeset
|
270 |
} |
8b887b2cb116
7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents:
10663
diff
changeset
|
271 |
|
1 | 272 |
private static final double FACTOR = 1024*1024; |
273 |
private void printValMB(String title, long value) { |
|
989
04e4dadeec8a
6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents:
1
diff
changeset
|
274 |
if (value < 0) { |
04e4dadeec8a
6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents:
1
diff
changeset
|
275 |
System.out.println(alignment + title + (value >>> 20) + " MB"); |
04e4dadeec8a
6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents:
1
diff
changeset
|
276 |
} else { |
04e4dadeec8a
6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents:
1
diff
changeset
|
277 |
double mb = value/FACTOR; |
04e4dadeec8a
6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents:
1
diff
changeset
|
278 |
System.out.println(alignment + title + value + " (" + mb + "MB)"); |
04e4dadeec8a
6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents:
1
diff
changeset
|
279 |
} |
1 | 280 |
} |
281 |
||
282 |
private void printValue(String title, long value) { |
|
283 |
System.out.println(alignment + title + value); |
|
284 |
} |
|
285 |
||
286 |
private long getFlagValue(String name, Map flagMap) { |
|
287 |
VM.Flag f = (VM.Flag) flagMap.get(name); |
|
288 |
if (f != null) { |
|
289 |
if (f.isBool()) { |
|
290 |
return f.getBool()? 1L : 0L; |
|
53517
20ba6a7f897a
8217850: CompressedClassSpaceSizeInJmapHeap fails after JDK-8217612
ysuenaga
parents:
52925
diff
changeset
|
291 |
} else if (f.isUIntx() || f.isSizet() || f.isUint64t()) { |
20ba6a7f897a
8217850: CompressedClassSpaceSizeInJmapHeap fails after JDK-8217612
ysuenaga
parents:
52925
diff
changeset
|
292 |
return Long.parseUnsignedLong(f.getValue()); |
1 | 293 |
} else { |
294 |
return Long.parseLong(f.getValue()); |
|
295 |
} |
|
296 |
} else { |
|
297 |
return -1; |
|
298 |
} |
|
299 |
} |
|
300 |
} |