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 jdk .test .lib .Platform ;
44
45
@@ -162,7 +163,9 @@ void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[],
162
163
163
164
public static void main (String [] args ) throws Exception {
164
165
new TestGCLogMessages ().testNormalLogs ();
165
- new TestGCLogMessages ().testWithToSpaceExhaustionLogs ();
166
+ if (Platform .isDebugBuild ()) {
167
+ new TestGCLogMessages ().testWithEvacuationFailureLogs ();
168
+ }
166
169
new TestGCLogMessages ().testWithInitialMark ();
167
170
new TestGCLogMessages ().testExpandHeap ();
168
171
}
@@ -203,12 +206,15 @@ private void testNormalLogs() throws Exception {
203
206
new LogMessageWithLevel ("Remove Self Forwards" , Level .TRACE ),
204
207
};
205
208
206
- private void testWithToSpaceExhaustionLogs () throws Exception {
209
+ private void testWithEvacuationFailureLogs () throws Exception {
207
210
ProcessBuilder pb = ProcessTools .createJavaProcessBuilder ("-XX:+UseG1GC" ,
208
211
"-Xmx32M" ,
209
212
"-Xmn16M" ,
213
+ "-XX:+G1EvacuationFailureALot" ,
214
+ "-XX:G1EvacuationFailureALotCount=100" ,
215
+ "-XX:G1EvacuationFailureALotInterval=1" ,
210
216
"-Xlog:gc+phases=debug" ,
211
- GCTestWithToSpaceExhaustion .class .getName ());
217
+ GCTestWithEvacuationFailure .class .getName ());
212
218
213
219
OutputAnalyzer output = new OutputAnalyzer (pb .start ());
214
220
checkMessagesAtLevel (output , exhFailureMessages , Level .DEBUG );
@@ -218,7 +224,7 @@ private void testWithToSpaceExhaustionLogs() throws Exception {
218
224
"-Xmx32M" ,
219
225
"-Xmn16M" ,
220
226
"-Xlog:gc+phases=trace" ,
221
- GCTestWithToSpaceExhaustion .class .getName ());
227
+ GCTestWithEvacuationFailure .class .getName ());
222
228
223
229
output = new OutputAnalyzer (pb .start ());
224
230
checkMessagesAtLevel (output , exhFailureMessages , Level .TRACE );
@@ -267,16 +273,19 @@ public static void main(String [] args) {
267
273
}
268
274
}
269
275
270
- static class GCTestWithToSpaceExhaustion {
276
+ static class GCTestWithEvacuationFailure {
271
277
private static byte [] garbage ;
272
278
private static byte [] largeObject ;
279
+ private static Object [] holder = new Object [200 ]; // Must be larger than G1EvacuationFailureALotCount
280
+
273
281
public static void main (String [] args ) {
274
282
largeObject = new byte [16 *1024 *1024 ];
275
283
System .out .println ("Creating garbage" );
276
- // create 128MB of garbage. This should result in at least one GC,
277
- // some of them with to-space exhaustion.
278
- for (int i = 0 ; i < 1024 ; i ++) {
279
- garbage = new byte [128 * 1024 ];
284
+ // Create 16 MB of garbage. This should result in at least one GC,
285
+ // (Heap size is 32M, we use 17MB for the large object above)
286
+ // which is larger than G1EvacuationFailureALotInterval.
287
+ for (int i = 0 ; i < 16 * 1024 ; i ++) {
288
+ holder [i % holder .length ] = new byte [1024 ];
280
289
}
281
290
System .out .println ("Done" );
282
291
}
0 commit comments