Skip to content

Commit cd66e0f

Browse files
author
Thomas Schatzl
committed
8253877: gc/g1/TestGCLogMessages.java fails - missing "Evacuation failure" message
Reviewed-by: sjohanss
1 parent e76de18 commit cd66e0f

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

test/hotspot/jtreg/gc/g1/TestGCLogMessages.java

+18-9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
*/
4040

4141
import jdk.test.lib.process.OutputAnalyzer;
42+
import jdk.test.lib.Platform;
4243
import jdk.test.lib.process.ProcessTools;
4344
import sun.hotspot.code.Compiler;
4445

@@ -182,7 +183,9 @@ void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[],
182183
public static void main(String[] args) throws Exception {
183184
new TestGCLogMessages().testNormalLogs();
184185
new TestGCLogMessages().testConcurrentRefinementLogs();
185-
new TestGCLogMessages().testWithToSpaceExhaustionLogs();
186+
if (Platform.isDebugBuild()) {
187+
new TestGCLogMessages().testWithEvacuationFailureLogs();
188+
}
186189
new TestGCLogMessages().testWithConcurrentStart();
187190
new TestGCLogMessages().testExpandHeap();
188191
}
@@ -240,12 +243,15 @@ private void testConcurrentRefinementLogs() throws Exception {
240243
new LogMessageWithLevel("Remove Self Forwards", Level.TRACE),
241244
};
242245

243-
private void testWithToSpaceExhaustionLogs() throws Exception {
246+
private void testWithEvacuationFailureLogs() throws Exception {
244247
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
245248
"-Xmx32M",
246249
"-Xmn16M",
250+
"-XX:+G1EvacuationFailureALot",
251+
"-XX:G1EvacuationFailureALotCount=100",
252+
"-XX:G1EvacuationFailureALotInterval=1",
247253
"-Xlog:gc+phases=debug",
248-
GCTestWithToSpaceExhaustion.class.getName());
254+
GCTestWithEvacuationFailure.class.getName());
249255

250256
OutputAnalyzer output = new OutputAnalyzer(pb.start());
251257
checkMessagesAtLevel(output, exhFailureMessages, Level.DEBUG);
@@ -255,7 +261,7 @@ private void testWithToSpaceExhaustionLogs() throws Exception {
255261
"-Xmx32M",
256262
"-Xmn16M",
257263
"-Xlog:gc+phases=trace",
258-
GCTestWithToSpaceExhaustion.class.getName());
264+
GCTestWithEvacuationFailure.class.getName());
259265

260266
output = new OutputAnalyzer(pb.start());
261267
checkMessagesAtLevel(output, exhFailureMessages, Level.TRACE);
@@ -304,16 +310,19 @@ public static void main(String [] args) {
304310
}
305311
}
306312

307-
static class GCTestWithToSpaceExhaustion {
313+
static class GCTestWithEvacuationFailure {
308314
private static byte[] garbage;
309315
private static byte[] largeObject;
316+
private static Object[] holder = new Object[200]; // Must be larger than G1EvacuationFailureALotCount
317+
310318
public static void main(String [] args) {
311319
largeObject = new byte[16*1024*1024];
312320
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];
317326
}
318327
System.out.println("Done");
319328
}

0 commit comments

Comments
 (0)