8068653: TestSmalllHeap.java fails when the page size is 64k
Reviewed-by: tschatzl
This commit is contained in:
parent
8d30377d50
commit
24d3bb517b
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,34 +26,46 @@
|
||||
* @bug 8067438
|
||||
* @requires vm.gc=="null"
|
||||
* @summary Verify that starting the VM with a small heap works
|
||||
* @library /testlibrary
|
||||
* @run main/othervm -Xmx4m -XX:+UseParallelGC TestSmallHeap
|
||||
* @run main/othervm -Xmx4m -XX:+UseSerialGC TestSmallHeap
|
||||
* @run main/othervm -Xmx4m -XX:+UseG1GC TestSmallHeap
|
||||
* @run main/othervm -Xmx4m -XX:+UseConcMarkSweepGC -XX:CMSMarkStackSizeMax=1032 TestSmallHeap
|
||||
* @library /testlibrary /../../test/lib
|
||||
* @build TestSmallHeap
|
||||
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseParallelGC TestSmallHeap
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseSerialGC TestSmallHeap
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseG1GC TestSmallHeap
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseConcMarkSweepGC TestSmallHeap
|
||||
*
|
||||
* Note: It would be nice to verify the minimal supported heap size (2m) here,
|
||||
* but we align the heap size based on the card table size. And the card table
|
||||
* size is aligned based on the minimal pages size provided by the os. This
|
||||
* means that on most platforms, where the minimal page size is 4k, we get a
|
||||
* minimal heap size of 2m but on Solaris/Sparc we have a page size of 8k and
|
||||
* get a minimal heap size of 4m. And on platforms where the page size is 64k
|
||||
* we get a minimal heap size of 32m. We never use large pages for the card table.
|
||||
*
|
||||
* Note: It would be nice to verify the minimal supported heap size here,
|
||||
* but that turns out to be quite tricky since we align the heap size based
|
||||
* on the card table size. And the card table size is aligned based on the
|
||||
* minimal pages size provided by the os. This means that on most platforms,
|
||||
* where the minimal page size is 4k, we get a minimal heap size of 2m but
|
||||
* on Solaris/Sparc we have a page size of 8k and get a minimal heap size
|
||||
* of 8m.
|
||||
* There is also no check in the VM for verifying that the maximum heap size
|
||||
* is larger than the supported minimal heap size. This means that specifying
|
||||
* -Xmx1m on the command line is fine but will give a heap of 2m (or 4m).
|
||||
* To work around these rather strange behaviors this test uses 4m for all
|
||||
* platforms.
|
||||
* -Xmx1m on the command line is fine but will give a heap of 2m (or 4m or 32m).
|
||||
*
|
||||
* To work around these rather strange behaviors this test uses -Xmx2m but then
|
||||
* calculates what the expected heap size should be. The calculation is a
|
||||
* simplified version of the code in the VM. We assume that the card table will
|
||||
* use one page. Each byte in the card table corresponds to 512 bytes on the heap.
|
||||
* So, the expected heap size is page_size * 512.
|
||||
*/
|
||||
|
||||
import sun.management.ManagementFactoryHelper;
|
||||
import com.oracle.java.testlibrary.*;
|
||||
import static com.oracle.java.testlibrary.Asserts.*;
|
||||
import sun.hotspot.WhiteBox;
|
||||
import sun.management.ManagementFactoryHelper;
|
||||
|
||||
public class TestSmallHeap {
|
||||
|
||||
public static void main(String[] args) {
|
||||
WhiteBox wb = WhiteBox.getWhiteBox();
|
||||
int pageSize = wb.getVMPageSize();
|
||||
int heapBytesPerCard = 512;
|
||||
long expectedMaxHeap = pageSize * heapBytesPerCard;
|
||||
String maxHeap = ManagementFactoryHelper.getDiagnosticMXBean().getVMOption("MaxHeapSize").getValue();
|
||||
String expectedMaxHeap = "4194304";
|
||||
assertEQ(maxHeap, expectedMaxHeap);
|
||||
assertEQ(Long.parseLong(maxHeap), expectedMaxHeap);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user