annotate agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java @ 3972:4f93f0d00802

7059019: G1: add G1 support to the SA Summary: Extend the SA to recognize the G1CollectedHeap and implement any code that's needed by our serviceability tools (jmap, jinfo, jstack, etc.) that depend on the SA. Reviewed-by: never, poonam, johnc
author tonyp
date Tue, 20 Sep 2011 09:59:59 -0400
parents c18cbe5936b8
children 81aa07130d30
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
2 * Copyright (c) 2003, 2011, 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.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.memory.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 public class HeapSummary extends Tool {
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public static void main(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 HeapSummary hs = new HeapSummary();
a61af66fc99e Initial load
duke
parents:
diff changeset
39 hs.start(args);
a61af66fc99e Initial load
duke
parents:
diff changeset
40 hs.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
41 }
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 CollectedHeap heap = VM.getVM().getUniverse().heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
45 VM.Flag[] flags = VM.getVM().getCommandLineFlags();
a61af66fc99e Initial load
duke
parents:
diff changeset
46 Map flagMap = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
47 if (flags == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 System.out.println("WARNING: command line flags are not available");
a61af66fc99e Initial load
duke
parents:
diff changeset
49 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 for (int f = 0; f < flags.length; f++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 flagMap.put(flags[f].getName(), flags[f]);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 System.out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 printGCAlgorithm(flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 System.out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
58 System.out.println("Heap Configuration:");
a61af66fc99e Initial load
duke
parents:
diff changeset
59 printValue("MinHeapFreeRatio = ", getFlagValue("MinHeapFreeRatio", flagMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
60 printValue("MaxHeapFreeRatio = ", getFlagValue("MaxHeapFreeRatio", flagMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
61 printValMB("MaxHeapSize = ", getFlagValue("MaxHeapSize", flagMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
62 printValMB("NewSize = ", getFlagValue("NewSize", flagMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
63 printValMB("MaxNewSize = ", getFlagValue("MaxNewSize", flagMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
64 printValMB("OldSize = ", getFlagValue("OldSize", flagMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
65 printValue("NewRatio = ", getFlagValue("NewRatio", flagMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
66 printValue("SurvivorRatio = ", getFlagValue("SurvivorRatio", flagMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
67 printValMB("PermSize = ", getFlagValue("PermSize", flagMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
68 printValMB("MaxPermSize = ", getFlagValue("MaxPermSize", flagMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 System.out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
71 System.out.println("Heap Usage:");
a61af66fc99e Initial load
duke
parents:
diff changeset
72
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
73 if (heap instanceof SharedHeap) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
74 SharedHeap sharedHeap = (SharedHeap) heap;
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
75 if (sharedHeap instanceof GenCollectedHeap) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
76 GenCollectedHeap genHeap = (GenCollectedHeap) sharedHeap;
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
77 for (int n = 0; n < genHeap.nGens(); n++) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
78 Generation gen = genHeap.getGen(n);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
79 if (gen instanceof sun.jvm.hotspot.memory.DefNewGeneration) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
80 System.out.println("New Generation (Eden + 1 Survivor Space):");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
81 printGen(gen);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
82
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
83 ContiguousSpace eden = ((DefNewGeneration)gen).eden();
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
84 System.out.println("Eden Space:");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
85 printSpace(eden);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
86
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
87 ContiguousSpace from = ((DefNewGeneration)gen).from();
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
88 System.out.println("From Space:");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
89 printSpace(from);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
91 ContiguousSpace to = ((DefNewGeneration)gen).to();
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
92 System.out.println("To Space:");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
93 printSpace(to);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
94 } else {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
95 System.out.println(gen.name() + ":");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
96 printGen(gen);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
97 }
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 } else if (sharedHeap instanceof G1CollectedHeap) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
100 G1CollectedHeap g1h = (G1CollectedHeap) sharedHeap;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
102 System.out.println("Garbage-First (G1) Heap");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
103 long capacityBytes = g1h.capacity();
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
104 long usedBytes = g1h.used();
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
105 long freeBytes = capacityBytes - usedBytes;
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
106 printValMB("region size = ", HeapRegion.grainBytes());
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
107 printValue("regions = ", g1h.n_regions());
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
108 printValMB("capacity = ", capacityBytes);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
109 printValMB("used = ", usedBytes);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
110 printValMB("free = ", freeBytes);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
111 System.out.println(alignment + (double) usedBytes * 100.0 / capacityBytes + "% used");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
112 } else {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
113 throw new RuntimeException("unknown SharedHeap type : " + heap.getClass());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
115 // Perm generation shared by the above
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
116 Generation permGen = sharedHeap.permGen();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
117 System.out.println("Perm Generation:");
a61af66fc99e Initial load
duke
parents:
diff changeset
118 printGen(permGen);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 } else if (heap instanceof ParallelScavengeHeap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 PSYoungGen youngGen = psh.youngGen();
a61af66fc99e Initial load
duke
parents:
diff changeset
122 printPSYoungGen(youngGen);
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 PSOldGen oldGen = psh.oldGen();
a61af66fc99e Initial load
duke
parents:
diff changeset
125 long oldFree = oldGen.capacity() - oldGen.used();
a61af66fc99e Initial load
duke
parents:
diff changeset
126 System.out.println("PS Old Generation");
a61af66fc99e Initial load
duke
parents:
diff changeset
127 printValMB("capacity = ", oldGen.capacity());
a61af66fc99e Initial load
duke
parents:
diff changeset
128 printValMB("used = ", oldGen.used());
a61af66fc99e Initial load
duke
parents:
diff changeset
129 printValMB("free = ", oldFree);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 System.out.println(alignment + (double)oldGen.used() * 100.0 / oldGen.capacity() + "% used");
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 PSPermGen permGen = psh.permGen();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 long permFree = permGen.capacity() - permGen.used();
a61af66fc99e Initial load
duke
parents:
diff changeset
134 System.out.println("PS Perm Generation");
a61af66fc99e Initial load
duke
parents:
diff changeset
135 printValMB("capacity = ", permGen.capacity());
a61af66fc99e Initial load
duke
parents:
diff changeset
136 printValMB("used = ", permGen.used());
a61af66fc99e Initial load
duke
parents:
diff changeset
137 printValMB("free = ", permFree);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 System.out.println(alignment + (double)permGen.used() * 100.0 / permGen.capacity() + "% used");
a61af66fc99e Initial load
duke
parents:
diff changeset
139 } else {
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
140 throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Helper methods
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 private void printGCAlgorithm(Map flagMap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // print about new generation
a61af66fc99e Initial load
duke
parents:
diff changeset
148 long l = getFlagValue("UseParNewGC", flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 if (l == 1L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 System.out.println("using parallel threads in the new generation.");
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 l = getFlagValue("UseTLAB", flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 if (l == 1L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 System.out.println("using thread-local object allocation.");
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 l = getFlagValue("UseConcMarkSweepGC", flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 if (l == 1L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 System.out.println("Concurrent Mark-Sweep GC");
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 l = getFlagValue("UseParallelGC", flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if (l == 1L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 System.out.print("Parallel GC ");
a61af66fc99e Initial load
duke
parents:
diff changeset
167 l = getFlagValue("ParallelGCThreads", flagMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 System.out.println("with " + l + " thread(s)");
a61af66fc99e Initial load
duke
parents:
diff changeset
169 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
172 l = getFlagValue("UseG1GC", flagMap);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
173 if (l == 1L) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
174 System.out.print("Garbage-First (G1) GC ");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
175 l = getFlagValue("ParallelGCThreads", flagMap);
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
176 System.out.println("with " + l + " thread(s)");
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
177 return;
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
178 }
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 1552
diff changeset
179
0
a61af66fc99e Initial load
duke
parents:
diff changeset
180 System.out.println("Mark Sweep Compact GC");
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 private void printPSYoungGen(PSYoungGen youngGen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 System.out.println("PS Young Generation");
a61af66fc99e Initial load
duke
parents:
diff changeset
185 MutableSpace eden = youngGen.edenSpace();
a61af66fc99e Initial load
duke
parents:
diff changeset
186 System.out.println("Eden Space:");
a61af66fc99e Initial load
duke
parents:
diff changeset
187 printMutableSpace(eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
188 MutableSpace from = youngGen.fromSpace();
a61af66fc99e Initial load
duke
parents:
diff changeset
189 System.out.println("From Space:");
a61af66fc99e Initial load
duke
parents:
diff changeset
190 printMutableSpace(from);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 MutableSpace to = youngGen.toSpace();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 System.out.println("To Space:");
a61af66fc99e Initial load
duke
parents:
diff changeset
193 printMutableSpace(to);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 private void printMutableSpace(MutableSpace space) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 printValMB("capacity = ", space.capacity());
a61af66fc99e Initial load
duke
parents:
diff changeset
198 printValMB("used = ", space.used());
a61af66fc99e Initial load
duke
parents:
diff changeset
199 long free = space.capacity() - space.used();
a61af66fc99e Initial load
duke
parents:
diff changeset
200 printValMB("free = ", free);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 System.out.println(alignment + (double)space.used() * 100.0 / space.capacity() + "% used");
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 private static String alignment = " ";
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 private void printGen(Generation gen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 printValMB("capacity = ", gen.capacity());
a61af66fc99e Initial load
duke
parents:
diff changeset
208 printValMB("used = ", gen.used());
a61af66fc99e Initial load
duke
parents:
diff changeset
209 printValMB("free = ", gen.free());
a61af66fc99e Initial load
duke
parents:
diff changeset
210 System.out.println(alignment + (double)gen.used() * 100.0 / gen.capacity() + "% used");
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 private void printSpace(ContiguousSpace space) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 printValMB("capacity = ", space.capacity());
a61af66fc99e Initial load
duke
parents:
diff changeset
215 printValMB("used = ", space.used());
a61af66fc99e Initial load
duke
parents:
diff changeset
216 printValMB("free = ", space.free());
a61af66fc99e Initial load
duke
parents:
diff changeset
217 System.out.println(alignment + (double)space.used() * 100.0 / space.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 static final double FACTOR = 1024*1024;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 private void printValMB(String title, long value) {
281
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
222 if (value < 0) {
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
223 System.out.println(alignment + title + (value >>> 20) + " MB");
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
224 } else {
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
225 double mb = value/FACTOR;
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
226 System.out.println(alignment + title + value + " (" + mb + "MB)");
a2de7dfbfcf0 6718125: SA: jmap prints negative size for MaxNewHeap.
swamyv
parents: 0
diff changeset
227 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 private void printValue(String title, long value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 System.out.println(alignment + title + value);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 private long getFlagValue(String name, Map flagMap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 VM.Flag f = (VM.Flag) flagMap.get(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 if (f != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 if (f.isBool()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 return f.getBool()? 1L : 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 return Long.parseLong(f.getValue());
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }