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 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import java.util.List; 25 import java.lang.management.*; 26 27 import jdk.test.lib.*; 28 import static jdk.test.lib.Asserts.*; 29 30 /* @test TestPerfCountersAndMemoryPools 31 * @bug 8023476 32 * @library /testlibrary 33 * @requires vm.gc.Serial 34 * @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace 35 * report the same data. 36 * @modules java.base/jdk.internal.misc 37 * java.management 38 * jdk.jvmstat/sun.jvmstat.monitor 39 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools 40 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools 41 */ 42 public class TestPerfCountersAndMemoryPools { 43 public static void main(String[] args) throws Exception { 44 checkMemoryUsage("Metaspace", "sun.gc.metaspace"); 45 46 if (InputArguments.contains("-XX:+UseCompressedClassPointers") && Platform.is64bit()) { 47 checkMemoryUsage("Compressed Class Space", "sun.gc.compressedclassspace"); 48 } 49 } 50 51 private static MemoryPoolMXBean getMemoryPool(String memoryPoolName) { 52 List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans(); | 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 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import java.util.List; 25 import java.lang.management.*; 26 27 import jdk.test.lib.Platform; 28 import static jdk.test.lib.Asserts.*; 29 30 /* @test TestPerfCountersAndMemoryPools 31 * @bug 8023476 32 * @library /test/lib 33 * @requires vm.gc.Serial 34 * @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace 35 * report the same data. 36 * @modules java.base/jdk.internal.misc 37 * java.management 38 * jdk.jvmstat/sun.jvmstat.monitor 39 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools 40 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools 41 */ 42 public class TestPerfCountersAndMemoryPools { 43 public static void main(String[] args) throws Exception { 44 checkMemoryUsage("Metaspace", "sun.gc.metaspace"); 45 46 if (InputArguments.contains("-XX:+UseCompressedClassPointers") && Platform.is64bit()) { 47 checkMemoryUsage("Compressed Class Space", "sun.gc.compressedclassspace"); 48 } 49 } 50 51 private static MemoryPoolMXBean getMemoryPool(String memoryPoolName) { 52 List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans(); |