39
39
*/
40
40
41
41
import jdk .test .lib .process .OutputAnalyzer ;
42
+ import jdk .test .lib .Platform ;
42
43
import jdk .test .lib .process .ProcessTools ;
43
44
import sun .hotspot .code .Compiler ;
44
45
@@ -182,7 +183,9 @@ void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[],
182
183
public static void main (String [] args ) throws Exception {
183
184
new TestGCLogMessages ().testNormalLogs ();
184
185
new TestGCLogMessages ().testConcurrentRefinementLogs ();
185
- new TestGCLogMessages ().testWithToSpaceExhaustionLogs ();
186
+ if (Platform .isDebugBuild ()) {
187
+ new TestGCLogMessages ().testWithEvacuationFailureLogs ();
188
+ }
186
189
new TestGCLogMessages ().testWithConcurrentStart ();
187
190
new TestGCLogMessages ().testExpandHeap ();
188
191
}
@@ -240,12 +243,15 @@ private void testConcurrentRefinementLogs() throws Exception {
240
243
new LogMessageWithLevel ("Remove Self Forwards" , Level .TRACE ),
241
244
};
242
245
243
- private void testWithToSpaceExhaustionLogs () throws Exception {
246
+ private void testWithEvacuationFailureLogs () throws Exception {
244
247
ProcessBuilder pb = ProcessTools .createJavaProcessBuilder ("-XX:+UseG1GC" ,
245
248
"-Xmx32M" ,
246
249
"-Xmn16M" ,
250
+ "-XX:+G1EvacuationFailureALot" ,
251
+ "-XX:G1EvacuationFailureALotCount=100" ,
252
+ "-XX:G1EvacuationFailureALotInterval=1" ,
247
253
"-Xlog:gc+phases=debug" ,
248
- GCTestWithToSpaceExhaustion .class .getName ());
254
+ GCTestWithEvacuationFailure .class .getName ());
249
255
250
256
OutputAnalyzer output = new OutputAnalyzer (pb .start ());
251
257
checkMessagesAtLevel (output , exhFailureMessages , Level .DEBUG );
@@ -255,7 +261,7 @@ private void testWithToSpaceExhaustionLogs() throws Exception {
255
261
"-Xmx32M" ,
256
262
"-Xmn16M" ,
257
263
"-Xlog:gc+phases=trace" ,
258
- GCTestWithToSpaceExhaustion .class .getName ());
264
+ GCTestWithEvacuationFailure .class .getName ());
259
265
260
266
output = new OutputAnalyzer (pb .start ());
261
267
checkMessagesAtLevel (output , exhFailureMessages , Level .TRACE );
@@ -304,16 +310,19 @@ public static void main(String [] args) {
304
310
}
305
311
}
306
312
307
- static class GCTestWithToSpaceExhaustion {
313
+ static class GCTestWithEvacuationFailure {
308
314
private static byte [] garbage ;
309
315
private static byte [] largeObject ;
316
+ private static Object [] holder = new Object [200 ]; // Must be larger than G1EvacuationFailureALotCount
317
+
310
318
public static void main (String [] args ) {
311
319
largeObject = new byte [16 *1024 *1024 ];
312
320
System .out .println ("Creating garbage" );
313
- // create 128MB of garbage. This should result in at least one GC,
314
- // some of them with to-space exhaustion.
315
- for (int i = 0 ; i < 1024 ; i ++) {
316
- garbage = new byte [128 * 1024 ];
321
+ // Create 16 MB of garbage. This should result in at least one GC,
322
+ // (Heap size is 32M, we use 17MB for the large object above)
323
+ // which is larger than G1EvacuationFailureALotInterval.
324
+ for (int i = 0 ; i < 16 * 1024 ; i ++) {
325
+ holder [i % holder .length ] = new byte [1024 ];
317
326
}
318
327
System .out .println ("Done" );
319
328
}
0 commit comments