changeset 12349:379ef2cc19c0

Merge
author ehelin
date Wed, 02 Oct 2013 18:24:58 +0200
parents 77a774ab3cf0 (current diff) 6e22e7042433 (diff)
children ab68fc0101ce
files
diffstat 1 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/test/gc/metaspace/TestPerfCountersAndMemoryPools.java	Wed Oct 02 14:33:32 2013 +0200
+++ b/test/gc/metaspace/TestPerfCountersAndMemoryPools.java	Wed Oct 02 18:24:58 2013 +0200
@@ -29,10 +29,11 @@
 
 /* @test TestPerfCountersAndMemoryPools
  * @bug 8023476
+ * @library /testlibrary
  * @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace
  *          report the same data.
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData TestPerfCountersAndMemoryPools
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData TestPerfCountersAndMemoryPools
+ * @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
  */
 public class TestPerfCountersAndMemoryPools {
     public static void main(String[] args) throws Exception {
@@ -43,11 +44,11 @@
         }
     }
 
-    private static MemoryUsage getMemoryUsage(String memoryPoolName) {
+    private static MemoryPoolMXBean getMemoryPool(String memoryPoolName) {
         List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
         for (MemoryPoolMXBean pool : pools) {
             if (pool.getName().equals(memoryPoolName)) {
-                return pool.getUsage();
+                return pool;
             }
         }
 
@@ -57,19 +58,18 @@
 
     private static void checkMemoryUsage(String memoryPoolName, String perfNS)
         throws Exception {
-        // Need to do a gc before each comparison to update the perf counters
+        MemoryPoolMXBean pool = getMemoryPool(memoryPoolName);
 
-        System.gc();
-        MemoryUsage mu = getMemoryUsage(memoryPoolName);
-        assertEQ(getMinCapacity(perfNS), mu.getInit());
-
+        // Must do a GC to update performance counters
         System.gc();
-        mu = getMemoryUsage(memoryPoolName);
-        assertEQ(getUsed(perfNS), mu.getUsed());
+        assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit());
 
+        // Must do a second GC to update the perfomance counters again, since
+        // the call pool.getUsage().getInit() could have allocated some
+        // metadata.
         System.gc();
-        mu = getMemoryUsage(memoryPoolName);
-        assertEQ(getCapacity(perfNS), mu.getCommitted());
+        assertEQ(getUsed(perfNS), pool.getUsage().getUsed());
+        assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted());
     }
 
     private static long getMinCapacity(String ns) throws Exception {