Wed, 06 Feb 2013 07:48:02 +0100
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
Reviewed-by: stefank, mgerdin
1.1 --- a/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java Tue Feb 26 22:31:35 2013 +0100 1.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java Wed Feb 06 07:48:02 2013 +0100 1.3 @@ -57,17 +57,18 @@ 1.4 printGCAlgorithm(flagMap); 1.5 System.out.println(); 1.6 System.out.println("Heap Configuration:"); 1.7 - printValue("MinHeapFreeRatio = ", getFlagValue("MinHeapFreeRatio", flagMap)); 1.8 - printValue("MaxHeapFreeRatio = ", getFlagValue("MaxHeapFreeRatio", flagMap)); 1.9 - printValMB("MaxHeapSize = ", getFlagValue("MaxHeapSize", flagMap)); 1.10 - printValMB("NewSize = ", getFlagValue("NewSize", flagMap)); 1.11 - printValMB("MaxNewSize = ", getFlagValue("MaxNewSize", flagMap)); 1.12 - printValMB("OldSize = ", getFlagValue("OldSize", flagMap)); 1.13 - printValue("NewRatio = ", getFlagValue("NewRatio", flagMap)); 1.14 - printValue("SurvivorRatio = ", getFlagValue("SurvivorRatio", flagMap)); 1.15 - printValMB("MetaspaceSize = ", getFlagValue("MetaspaceSize", flagMap)); 1.16 - printValMB("MaxMetaspaceSize = ", getFlagValue("MaxMetaspaceSize", flagMap)); 1.17 - printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes()); 1.18 + printValue("MinHeapFreeRatio = ", getFlagValue("MinHeapFreeRatio", flagMap)); 1.19 + printValue("MaxHeapFreeRatio = ", getFlagValue("MaxHeapFreeRatio", flagMap)); 1.20 + printValMB("MaxHeapSize = ", getFlagValue("MaxHeapSize", flagMap)); 1.21 + printValMB("NewSize = ", getFlagValue("NewSize", flagMap)); 1.22 + printValMB("MaxNewSize = ", getFlagValue("MaxNewSize", flagMap)); 1.23 + printValMB("OldSize = ", getFlagValue("OldSize", flagMap)); 1.24 + printValue("NewRatio = ", getFlagValue("NewRatio", flagMap)); 1.25 + printValue("SurvivorRatio = ", getFlagValue("SurvivorRatio", flagMap)); 1.26 + printValMB("MetaspaceSize = ", getFlagValue("MetaspaceSize", flagMap)); 1.27 + printValMB("ClassMetaspaceSize = ", getFlagValue("ClassMetaspaceSize", flagMap)); 1.28 + printValMB("MaxMetaspaceSize = ", getFlagValue("MaxMetaspaceSize", flagMap)); 1.29 + printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes()); 1.30 1.31 System.out.println(); 1.32 System.out.println("Heap Usage:");
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java Wed Feb 06 07:48:02 2013 +0100 2.3 @@ -0,0 +1,77 @@ 2.4 +/* 2.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 + 2.27 +/* 2.28 + * @test ClassMetaspaceSizeInJmapHeap 2.29 + * @bug 8004924 2.30 + * @summary Checks that jmap -heap contains the flag ClassMetaspaceSize 2.31 + * @library /testlibrary 2.32 + * @run main/othervm -XX:ClassMetaspaceSize=50m ClassMetaspaceSizeInJmapHeap 2.33 + */ 2.34 + 2.35 +import com.oracle.java.testlibrary.*; 2.36 +import java.nio.file.*; 2.37 +import java.io.File; 2.38 +import java.nio.charset.Charset; 2.39 +import java.util.List; 2.40 + 2.41 +public class ClassMetaspaceSizeInJmapHeap { 2.42 + public static void main(String[] args) throws Exception { 2.43 + String pid = Integer.toString(ProcessTools.getProcessId()); 2.44 + 2.45 + ProcessBuilder pb = new ProcessBuilder(); 2.46 + pb.command(JDKToolFinder.getJDKTool("jmap"), "-heap", pid); 2.47 + 2.48 + File out = new File("ClassMetaspaceSizeInJmapHeap.stdout.txt"); 2.49 + pb.redirectOutput(out); 2.50 + 2.51 + File err = new File("ClassMetaspaceSizeInJmapHeap.stderr.txt"); 2.52 + pb.redirectError(err); 2.53 + 2.54 + run(pb); 2.55 + 2.56 + OutputAnalyzer output = new OutputAnalyzer(read(out)); 2.57 + output.shouldContain("ClassMetaspaceSize = 52428800 (50.0MB)"); 2.58 + out.delete(); 2.59 + } 2.60 + 2.61 + private static void run(ProcessBuilder pb) throws Exception { 2.62 + Process p = pb.start(); 2.63 + p.waitFor(); 2.64 + int exitValue = p.exitValue(); 2.65 + if (exitValue != 0) { 2.66 + throw new Exception("jmap -heap exited with error code: " + exitValue); 2.67 + } 2.68 + } 2.69 + 2.70 + private static String read(File f) throws Exception { 2.71 + Path p = f.toPath(); 2.72 + List<String> lines = Files.readAllLines(p, Charset.defaultCharset()); 2.73 + 2.74 + StringBuilder sb = new StringBuilder(); 2.75 + for (String line : lines) { 2.76 + sb.append(line).append('\n'); 2.77 + } 2.78 + return sb.toString(); 2.79 + } 2.80 +}