Merge

Wed, 02 Oct 2013 18:24:58 +0200

author
ehelin
date
Wed, 02 Oct 2013 18:24:58 +0200
changeset 5817
379ef2cc19c0
parent 5815
77a774ab3cf0
parent 5816
6e22e7042433
child 5818
ab68fc0101ce

Merge

     1.1 --- a/test/gc/metaspace/TestPerfCountersAndMemoryPools.java	Wed Oct 02 14:33:32 2013 +0200
     1.2 +++ b/test/gc/metaspace/TestPerfCountersAndMemoryPools.java	Wed Oct 02 18:24:58 2013 +0200
     1.3 @@ -29,10 +29,11 @@
     1.4  
     1.5  /* @test TestPerfCountersAndMemoryPools
     1.6   * @bug 8023476
     1.7 + * @library /testlibrary
     1.8   * @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace
     1.9   *          report the same data.
    1.10 - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData TestPerfCountersAndMemoryPools
    1.11 - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData TestPerfCountersAndMemoryPools
    1.12 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
    1.13 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
    1.14   */
    1.15  public class TestPerfCountersAndMemoryPools {
    1.16      public static void main(String[] args) throws Exception {
    1.17 @@ -43,11 +44,11 @@
    1.18          }
    1.19      }
    1.20  
    1.21 -    private static MemoryUsage getMemoryUsage(String memoryPoolName) {
    1.22 +    private static MemoryPoolMXBean getMemoryPool(String memoryPoolName) {
    1.23          List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
    1.24          for (MemoryPoolMXBean pool : pools) {
    1.25              if (pool.getName().equals(memoryPoolName)) {
    1.26 -                return pool.getUsage();
    1.27 +                return pool;
    1.28              }
    1.29          }
    1.30  
    1.31 @@ -57,19 +58,18 @@
    1.32  
    1.33      private static void checkMemoryUsage(String memoryPoolName, String perfNS)
    1.34          throws Exception {
    1.35 -        // Need to do a gc before each comparison to update the perf counters
    1.36 +        MemoryPoolMXBean pool = getMemoryPool(memoryPoolName);
    1.37  
    1.38 +        // Must do a GC to update performance counters
    1.39          System.gc();
    1.40 -        MemoryUsage mu = getMemoryUsage(memoryPoolName);
    1.41 -        assertEQ(getMinCapacity(perfNS), mu.getInit());
    1.42 +        assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit());
    1.43  
    1.44 +        // Must do a second GC to update the perfomance counters again, since
    1.45 +        // the call pool.getUsage().getInit() could have allocated some
    1.46 +        // metadata.
    1.47          System.gc();
    1.48 -        mu = getMemoryUsage(memoryPoolName);
    1.49 -        assertEQ(getUsed(perfNS), mu.getUsed());
    1.50 -
    1.51 -        System.gc();
    1.52 -        mu = getMemoryUsage(memoryPoolName);
    1.53 -        assertEQ(getCapacity(perfNS), mu.getCommitted());
    1.54 +        assertEQ(getUsed(perfNS), pool.getUsage().getUsed());
    1.55 +        assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted());
    1.56      }
    1.57  
    1.58      private static long getMinCapacity(String ns) throws Exception {

mercurial