hotspot/test/gc/TestSmallHeap.java
changeset 30247 9925b07bba5b
parent 29678 dd2f3932c21e
child 30604 b8d532cb6420
equal deleted inserted replaced
30246:97d51729447c 30247:9925b07bba5b
    56  * use one page. Each byte in the card table corresponds to 512 bytes on the heap.
    56  * use one page. Each byte in the card table corresponds to 512 bytes on the heap.
    57  * So, the expected heap size is page_size * 512.
    57  * So, the expected heap size is page_size * 512.
    58  */
    58  */
    59 
    59 
    60 import com.oracle.java.testlibrary.*;
    60 import com.oracle.java.testlibrary.*;
       
    61 import com.sun.management.HotSpotDiagnosticMXBean;
       
    62 import java.lang.management.ManagementFactory;
    61 import static com.oracle.java.testlibrary.Asserts.*;
    63 import static com.oracle.java.testlibrary.Asserts.*;
       
    64 
    62 import sun.hotspot.WhiteBox;
    65 import sun.hotspot.WhiteBox;
    63 import sun.management.ManagementFactoryHelper;
       
    64 
    66 
    65 public class TestSmallHeap {
    67 public class TestSmallHeap {
    66 
    68 
    67     public static void main(String[] args) {
    69     public static void main(String[] args) {
    68         WhiteBox wb = WhiteBox.getWhiteBox();
    70         WhiteBox wb = WhiteBox.getWhiteBox();
    69         int pageSize = wb.getVMPageSize();
    71         int pageSize = wb.getVMPageSize();
    70         int heapBytesPerCard = 512;
    72         int heapBytesPerCard = 512;
    71         long expectedMaxHeap = pageSize * heapBytesPerCard;
    73         long expectedMaxHeap = pageSize * heapBytesPerCard;
    72         String maxHeap = ManagementFactoryHelper.getDiagnosticMXBean().getVMOption("MaxHeapSize").getValue();
    74         String maxHeap
       
    75             = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class)
       
    76                 .getVMOption("MaxHeapSize").getValue();
    73         assertEQ(Long.parseLong(maxHeap), expectedMaxHeap);
    77         assertEQ(Long.parseLong(maxHeap), expectedMaxHeap);
    74     }
    78     }
    75 }
    79 }