changeset 39981:eb1282859915

8160827: gc/stress/TestStressG1Humongous.java fails with OOME Reviewed-by: tschatzl
author mchernov
date Tue, 19 Jul 2016 18:15:46 +0300
parents dcef6760667c
children 295ff7a5e92d 8ecc78131588 66623d85bbd8
files hotspot/test/gc/stress/TestStressG1Humongous.java
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/test/gc/stress/TestStressG1Humongous.java	Tue Jul 19 09:30:30 2016 +0200
+++ b/hotspot/test/gc/stress/TestStressG1Humongous.java	Tue Jul 19 18:15:46 2016 +0300
@@ -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;
     }