--- old/test/gc/metaspace/TestMetaspacePerfCounters.java 2016-03-22 13:48:00.443640749 +0100 +++ new/test/gc/metaspace/TestMetaspacePerfCounters.java 2016-03-22 13:48:00.307635456 +0100 @@ -84,6 +84,9 @@ } private static void checkUsedIncreasesWhenLoadingClass(String ns) throws Exception { + // Need to ensure that used is up to date and the all unloadable + // classes are unloaded before doing this check. + System.gc(); long before = getUsed(ns); fooClass = compileAndLoad("Foo", "public class Foo { }"); System.gc(); --- old/test/gc/metaspace/TestPerfCountersAndMemoryPools.java 2016-03-22 13:48:01.055664568 +0100 +++ new/test/gc/metaspace/TestPerfCountersAndMemoryPools.java 2016-03-22 13:48:00.951660520 +0100 @@ -36,14 +36,14 @@ * @modules java.base/sun.misc * java.management * jdk.jvmstat/sun.jvmstat.monitor - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools */ public class TestPerfCountersAndMemoryPools { public static void main(String[] args) throws Exception { checkMemoryUsage("Metaspace", "sun.gc.metaspace"); - if (InputArguments.contains("-XX:+UseCompressedKlassPointers") && Platform.is64bit()) { + if (InputArguments.contains("-XX:+UseCompressedClassPointers") && Platform.is64bit()) { checkMemoryUsage("Compressed Class Space", "sun.gc.compressedclassspace"); } } @@ -71,13 +71,17 @@ pool.getUsage().getInit(); pool.getUsage().getUsed(); pool.getUsage().getCommitted(); - assertEQ(1L, 1L); + assertEQ(1L, 1L, "Make assert load"); // Must do a GC to update performance counters System.gc(); - assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit()); - assertEQ(getUsed(perfNS), pool.getUsage().getUsed()); - assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted()); + assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit(), "MinCapacity out of sync"); + + // Adding a second GC due to metadata allocations caused caused by getting + // initial size from the pool. This is needed when running with -Xcomp. + System.gc(); + assertEQ(getUsed(perfNS), pool.getUsage().getUsed(), "Used out of sync"); + assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted(), "Committed out of sync"); } private static long getMinCapacity(String ns) throws Exception {