# HG changeset patch # User jiangli # Date 1468951626 -7200 # Node ID 66623d85bbd8432d45ddaa5777f7e89560ff5e5f # Parent 416a95f29c6a80e4fd17af400ac80635eb30b6a5# Parent eb128285991548c95284af0ab86c89ef4836e10a Merge diff -r 416a95f29c6a -r 66623d85bbd8 hotspot/test/gc/stress/TestStressG1Humongous.java --- a/hotspot/test/gc/stress/TestStressG1Humongous.java Tue Jul 19 13:52:14 2016 -0400 +++ b/hotspot/test/gc/stress/TestStressG1Humongous.java Tue Jul 19 20:07:06 2016 +0200 @@ -26,9 +26,6 @@ * @key gc * @key stress * @summary Stress G1 by humongous allocations in situation near OOM - * Fails intermittently on 32-bit VMs due to 8160827 so quarantine - * it on those platforms: - * @requires vm.bits != "32" * @requires vm.gc.G1 * @requires !vm.flightRecorder * @run main/othervm/timeout=200 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=4m @@ -56,6 +53,7 @@ private static final int THREAD_COUNT = Integer.getInteger("threads", 2); private static final int REGION_SIZE = Integer.getInteger("regionsize", 1) * 1024 * 1024; private static final int HUMONGOUS_SIZE = (int) (REGION_SIZE * Double.parseDouble(System.getProperty("humongoussize", "1.5"))); + private static final int NUMBER_OF_FREE_REGIONS = 2; private volatile boolean isRunning; private final ExecutorService threadExecutor; @@ -95,8 +93,12 @@ private int getExpectedAmountOfObjects() { long maxMem = Runtime.getRuntime().maxMemory(); int expectedHObjects = (int) (maxMem / HUMONGOUS_SIZE); - // Will allocate 1 region less to give some free space for VM. - int checkedAmountOfHObjects = checkHeapCapacity(expectedHObjects) - 1; + // Will allocate NUMBER_OF_FREE_REGIONS region less to give some free space for VM. + int checkedAmountOfHObjects = checkHeapCapacity(expectedHObjects) - NUMBER_OF_FREE_REGIONS; + if (checkedAmountOfHObjects <= 0) { + throw new RuntimeException("Cannot start testing because selected maximum heap " + + "is not large enough to contain more than " + NUMBER_OF_FREE_REGIONS + " regions"); + } return checkedAmountOfHObjects; }