8210193: [TESTBUG]gc/g1/mixedgc/TestOldGenCollectionUsage.java fails intermittently with OutOfMemoryError in CDS mode.
Summary: Increase java heap size in TestOldGenCollectionUsage. Catch OOM in tests.
Reviewed-by: phh, iklam
--- a/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java Thu Sep 13 14:15:27 2018 -0300
+++ b/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java Thu Sep 13 13:30:07 2018 -0400
@@ -166,7 +166,14 @@
System.out.println("Allocating new objects to provoke mixed GC");
// allocate more objects to provoke GC
for (int i = 0; i < (TestLogging.ALLOCATION_COUNT * 20); i++) {
- newObjects.add(new byte[TestLogging.ALLOCATION_SIZE]);
+ try {
+ newObjects.add(new byte[TestLogging.ALLOCATION_SIZE]);
+ } catch (OutOfMemoryError e) {
+ newObjects.clear();
+ WB.youngGC();
+ WB.youngGC();
+ break;
+ }
}
// check that liveOldObjects still alive
Asserts.assertTrue(WB.isObjectInOldGen(liveOldObjects),
--- 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),