hotspot/test/gc/metaspace/TestPerfCountersAndMemoryPools.java
changeset 37267 ad8c0e8de29f
parent 36847 3b6a93156b10
parent 37244 9b8f2dc281ad
child 37297 d65d53a0ecc7
equal deleted inserted replaced
36848:33688f44fb2a 37267:ad8c0e8de29f
    34  * @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace
    34  * @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace
    35  *          report the same data.
    35  *          report the same data.
    36  * @modules java.base/sun.misc
    36  * @modules java.base/sun.misc
    37  *          java.management
    37  *          java.management
    38  *          jdk.jvmstat/sun.jvmstat.monitor
    38  *          jdk.jvmstat/sun.jvmstat.monitor
    39  * @ignore 8151460
    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:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
    40  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
    41  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
       
    42  */
    41  */
    43 public class TestPerfCountersAndMemoryPools {
    42 public class TestPerfCountersAndMemoryPools {
    44     public static void main(String[] args) throws Exception {
    43     public static void main(String[] args) throws Exception {
    45         checkMemoryUsage("Metaspace", "sun.gc.metaspace");
    44         checkMemoryUsage("Metaspace", "sun.gc.metaspace");
    46 
    45 
    47         if (InputArguments.contains("-XX:+UseCompressedKlassPointers") && Platform.is64bit()) {
    46         if (InputArguments.contains("-XX:+UseCompressedClassPointers") && Platform.is64bit()) {
    48             checkMemoryUsage("Compressed Class Space", "sun.gc.compressedclassspace");
    47             checkMemoryUsage("Compressed Class Space", "sun.gc.compressedclassspace");
    49         }
    48         }
    50     }
    49     }
    51 
    50 
    52     private static MemoryPoolMXBean getMemoryPool(String memoryPoolName) {
    51     private static MemoryPoolMXBean getMemoryPool(String memoryPoolName) {
    70         getCapacity(perfNS);
    69         getCapacity(perfNS);
    71         getUsed(perfNS);
    70         getUsed(perfNS);
    72         pool.getUsage().getInit();
    71         pool.getUsage().getInit();
    73         pool.getUsage().getUsed();
    72         pool.getUsage().getUsed();
    74         pool.getUsage().getCommitted();
    73         pool.getUsage().getCommitted();
    75         assertEQ(1L, 1L);
    74         assertEQ(1L, 1L, "Make assert load");
    76 
    75 
    77         // Must do a GC to update performance counters
    76         // Must do a GC to update performance counters
    78         System.gc();
    77         System.gc();
    79         assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit());
    78         assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit(), "MinCapacity out of sync");
    80         assertEQ(getUsed(perfNS), pool.getUsage().getUsed());
    79 
    81         assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted());
    80         // Adding a second GC due to metadata allocations caused by getting the
       
    81         // initial size from the pool. This is needed when running with -Xcomp.
       
    82         System.gc();
       
    83         assertEQ(getUsed(perfNS), pool.getUsage().getUsed(), "Used out of sync");
       
    84         assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted(), "Committed out of sync");
    82     }
    85     }
    83 
    86 
    84     private static long getMinCapacity(String ns) throws Exception {
    87     private static long getMinCapacity(String ns) throws Exception {
    85         return PerfCounters.findByName(ns + ".minCapacity").longValue();
    88         return PerfCounters.findByName(ns + ".minCapacity").longValue();
    86     }
    89     }