test/hotspot/jtreg/gc/shenandoah/mxbeans/TestMemoryMXBeans.java
changeset 53873 5cf6623b1283
parent 52925 9c18c9d839d3
child 54478 cdc54443fee5
equal deleted inserted replaced
53872:cc9359f8c563 53873:5cf6623b1283
    50     }
    50     }
    51 
    51 
    52     public static void testMemoryBean(long initSize, long maxSize) {
    52     public static void testMemoryBean(long initSize, long maxSize) {
    53         MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
    53         MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
    54         long heapInit = memoryMXBean.getHeapMemoryUsage().getInit();
    54         long heapInit = memoryMXBean.getHeapMemoryUsage().getInit();
       
    55         long heapCommitted = memoryMXBean.getHeapMemoryUsage().getCommitted();
    55         long heapMax = memoryMXBean.getHeapMemoryUsage().getMax();
    56         long heapMax = memoryMXBean.getHeapMemoryUsage().getMax();
    56         long nonHeapInit = memoryMXBean.getNonHeapMemoryUsage().getInit();
    57         long nonHeapInit = memoryMXBean.getNonHeapMemoryUsage().getInit();
       
    58         long nonHeapCommitted = memoryMXBean.getNonHeapMemoryUsage().getCommitted();
    57         long nonHeapMax = memoryMXBean.getNonHeapMemoryUsage().getMax();
    59         long nonHeapMax = memoryMXBean.getNonHeapMemoryUsage().getMax();
    58 
    60 
    59         if (initSize > 0 && heapInit != initSize) {
    61         if (initSize > 0 && heapInit != initSize) {
    60             throw new IllegalStateException("Init heap size is wrong: " + heapInit + " vs " + initSize);
    62             throw new IllegalStateException("Init heap size is wrong: " + heapInit + " vs " + initSize);
    61         }
    63         }
    62         if (maxSize > 0 && heapMax != maxSize) {
    64         if (maxSize > 0 && heapMax != maxSize) {
    63             throw new IllegalStateException("Max heap size is wrong: " + heapMax + " vs " + maxSize);
    65             throw new IllegalStateException("Max heap size is wrong: " + heapMax + " vs " + maxSize);
    64         }
    66         }
       
    67         if (initSize > 0 && maxSize > 0 && initSize != maxSize && heapCommitted == heapMax) {
       
    68             throw new IllegalStateException("Init committed heap size is wrong: " + heapCommitted +
       
    69                                             " (init: " + initSize + ", max: " + maxSize + ")");
       
    70         }
    65     }
    71     }
    66 }
    72 }