< prev index next >
test/gc/stress/TestStressG1Humongous.java
Print this page
@@ -24,13 +24,10 @@
/*
* @test TestStressG1Humongous
* @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
* -Dtimeout=120 -Dthreads=3 -Dhumongoussize=1.1 -Dregionsize=4 TestStressG1Humongous
* @run main/othervm/timeout=200 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=16m
@@ -93,12 +90,15 @@
* @return expected amount of humongous objects
*/
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 2 region less to give some free space for VM.
+ int checkedAmountOfHObjects = checkHeapCapacity(expectedHObjects) - 2;
+ if (checkedAmountOfHObjects <= 0) {
+ throw new RuntimeException("Cannot start testing because there is no available memory.");
+ }
return checkedAmountOfHObjects;
}
/**
* Starts several threads to allocate the requested amount of humongous objects.
< prev index next >