Skip to content

Commit c9d5eb3

Browse files
committed
8253877: gc/g1/TestGCLogMessages.java fails - missing "Evacuation failure" message
Backport-of: cd66e0f
1 parent 4b2941d commit c9d5eb3

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 jdk.test.lib.Platform;
4445

@@ -162,7 +163,9 @@ void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[],
162163

163164
public static void main(String[] args) throws Exception {
164165
new TestGCLogMessages().testNormalLogs();
165-
new TestGCLogMessages().testWithToSpaceExhaustionLogs();
166+
if (Platform.isDebugBuild()) {
167+
new TestGCLogMessages().testWithEvacuationFailureLogs();
168+
}
166169
new TestGCLogMessages().testWithInitialMark();
167170
new TestGCLogMessages().testExpandHeap();
168171
}
@@ -203,12 +206,15 @@ private void testNormalLogs() throws Exception {
203206
new LogMessageWithLevel("Remove Self Forwards", Level.TRACE),
204207
};
205208

206-
private void testWithToSpaceExhaustionLogs() throws Exception {
209+
private void testWithEvacuationFailureLogs() throws Exception {
207210
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
208211
"-Xmx32M",
209212
"-Xmn16M",
213+
"-XX:+G1EvacuationFailureALot",
214+
"-XX:G1EvacuationFailureALotCount=100",
215+
"-XX:G1EvacuationFailureALotInterval=1",
210216
"-Xlog:gc+phases=debug",
211-
GCTestWithToSpaceExhaustion.class.getName());
217+
GCTestWithEvacuationFailure.class.getName());
212218

213219
OutputAnalyzer output = new OutputAnalyzer(pb.start());
214220
checkMessagesAtLevel(output, exhFailureMessages, Level.DEBUG);
@@ -218,7 +224,7 @@ private void testWithToSpaceExhaustionLogs() throws Exception {
218224
"-Xmx32M",
219225
"-Xmn16M",
220226
"-Xlog:gc+phases=trace",
221-
GCTestWithToSpaceExhaustion.class.getName());
227+
GCTestWithEvacuationFailure.class.getName());
222228

223229
output = new OutputAnalyzer(pb.start());
224230
checkMessagesAtLevel(output, exhFailureMessages, Level.TRACE);
@@ -267,16 +273,19 @@ public static void main(String [] args) {
267273
}
268274
}
269275

270-
static class GCTestWithToSpaceExhaustion {
276+
static class GCTestWithEvacuationFailure {
271277
private static byte[] garbage;
272278
private static byte[] largeObject;
279+
private static Object[] holder = new Object[200]; // Must be larger than G1EvacuationFailureALotCount
280+
273281
public static void main(String [] args) {
274282
largeObject = new byte[16*1024*1024];
275283
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];
280289
}
281290
System.out.println("Done");
282291
}

0 commit comments

Comments
 (0)