hotspot/test/gc/metaspace/TestPerfCountersAndMemoryPools.java
changeset 37244 9b8f2dc281ad
parent 35373 51858d53abfb
child 37267 ad8c0e8de29f
--- a/hotspot/test/gc/metaspace/TestPerfCountersAndMemoryPools.java	Mon Apr 04 11:32:04 2016 +0200
+++ b/hotspot/test/gc/metaspace/TestPerfCountersAndMemoryPools.java	Thu Mar 24 10:49:08 2016 +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 by getting the
+        // 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 {