test/hotspot/jtreg/gc/g1/mixedgc/TestOldGenCollectionUsage.java
changeset 51726 a3989376ade2
parent 50635 5d3c5af82654
child 53475 6130409b923e
--- a/test/hotspot/jtreg/gc/g1/mixedgc/TestOldGenCollectionUsage.java	Thu Sep 13 14:15:27 2018 -0300
+++ b/test/hotspot/jtreg/gc/g1/mixedgc/TestOldGenCollectionUsage.java	Thu Sep 13 13:30:07 2018 -0400
@@ -33,7 +33,7 @@
  * @modules java.management
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
- * @run main/othervm -Xbootclasspath/a:. -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -verbose:gc -XX:SurvivorRatio=1 -Xmx12m -Xms12m -XX:MaxTenuringThreshold=1 -XX:InitiatingHeapOccupancyPercent=100 -XX:-G1UseAdaptiveIHOP -XX:G1MixedGCCountTarget=4 -XX:MaxGCPauseMillis=30000 -XX:G1HeapRegionSize=1m -XX:G1HeapWastePercent=0 -XX:G1MixedGCLiveThresholdPercent=100 TestOldGenCollectionUsage
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -verbose:gc -XX:SurvivorRatio=1 -Xmx14m -Xms14m -XX:MaxTenuringThreshold=1 -XX:InitiatingHeapOccupancyPercent=100 -XX:-G1UseAdaptiveIHOP -XX:G1MixedGCCountTarget=4 -XX:MaxGCPauseMillis=30000 -XX:G1HeapRegionSize=1m -XX:G1HeapWastePercent=0 -XX:G1MixedGCLiveThresholdPercent=100 TestOldGenCollectionUsage
  */
 
 import jdk.test.lib.Asserts;
@@ -209,7 +209,15 @@
             // Provoke a mixed collection. G1MixedGCLiveThresholdPercent=100
             // guarantees that full old gen regions will be included.
             for (int i = 0; i < (ALLOCATION_COUNT * 20); i++) {
-                newObjects.add(new byte[ALLOCATION_SIZE]);
+                try {
+                    newObjects.add(new byte[ALLOCATION_SIZE]);
+                } catch (OutOfMemoryError e) {
+                    newObjects.clear();
+                    WB.youngGC();
+                    WB.youngGC();
+                    System.out.println("OutOfMemoryError is reported, stop allocating new objects");
+                    break;
+                }
             }
             // check that liveOldObjects still alive
             Asserts.assertTrue(WB.isObjectInOldGen(liveOldObjects),