8192983: gc/g1/TestVerifyGCType.java might fail on loaded machines
Reviewed-by: tschatzl, jwilhelm
This commit is contained in:
parent
5fb516acc0
commit
657b951fab
@ -142,8 +142,9 @@ public class TestVerifyGCType {
|
|||||||
"-XX:+UnlockDiagnosticVMOptions",
|
"-XX:+UnlockDiagnosticVMOptions",
|
||||||
"-XX:+UseG1GC",
|
"-XX:+UseG1GC",
|
||||||
"-XX:+WhiteBoxAPI",
|
"-XX:+WhiteBoxAPI",
|
||||||
"-XX:+ExplicitGCInvokesConcurrent",
|
|
||||||
"-Xlog:gc,gc+start,gc+verify=info",
|
"-Xlog:gc,gc+start,gc+verify=info",
|
||||||
|
"-Xms16m",
|
||||||
|
"-Xmx16m",
|
||||||
"-XX:+VerifyBeforeGC",
|
"-XX:+VerifyBeforeGC",
|
||||||
"-XX:+VerifyAfterGC",
|
"-XX:+VerifyAfterGC",
|
||||||
"-XX:+VerifyDuringGC"});
|
"-XX:+VerifyDuringGC"});
|
||||||
@ -173,7 +174,7 @@ public class TestVerifyGCType {
|
|||||||
|
|
||||||
private static void verifyCollection(String name, boolean expectBefore, boolean expectDuring, boolean expectAfter, String data) {
|
private static void verifyCollection(String name, boolean expectBefore, boolean expectDuring, boolean expectAfter, String data) {
|
||||||
CollectionInfo ci = CollectionInfo.parseFirst(name, data);
|
CollectionInfo ci = CollectionInfo.parseFirst(name, data);
|
||||||
Asserts.assertTrue(ci != null, "Expected GC not found: " + name);
|
Asserts.assertTrue(ci != null, "Expected GC not found: " + name + "\n" + data);
|
||||||
|
|
||||||
// Verify Before
|
// Verify Before
|
||||||
verifyType(ci, expectBefore, VERIFY_BEFORE);
|
verifyType(ci, expectBefore, VERIFY_BEFORE);
|
||||||
@ -243,14 +244,41 @@ public class TestVerifyGCType {
|
|||||||
public static class TriggerGCs {
|
public static class TriggerGCs {
|
||||||
public static void main(String args[]) throws Exception {
|
public static void main(String args[]) throws Exception {
|
||||||
WhiteBox wb = WhiteBox.getWhiteBox();
|
WhiteBox wb = WhiteBox.getWhiteBox();
|
||||||
// Trigger the different GCs using the WhiteBox API and System.gc()
|
// Allocate some memory that can be turned into garbage.
|
||||||
// to start a concurrent cycle with -XX:+ExplicitGCInvokesConcurrent.
|
Object[] used = alloc1M();
|
||||||
|
|
||||||
|
// Trigger the different GCs using the WhiteBox API.
|
||||||
wb.fullGC(); // full
|
wb.fullGC(); // full
|
||||||
System.gc(); // initial-mark, remark and cleanup
|
|
||||||
|
// Memory have been promoted to old by full GC. Free
|
||||||
|
// some memory to be reclaimed by concurrent cycle.
|
||||||
|
partialFree(used);
|
||||||
|
wb.g1StartConcMarkCycle(); // initial-mark, remark and cleanup
|
||||||
|
|
||||||
// Sleep to make sure concurrent cycle is done
|
// Sleep to make sure concurrent cycle is done
|
||||||
Thread.sleep(1000);
|
while (wb.g1InConcurrentMark()) {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trigger two young GCs, first will be young-only, second will be mixed.
|
||||||
wb.youngGC(); // young-only
|
wb.youngGC(); // young-only
|
||||||
wb.youngGC(); // mixed
|
wb.youngGC(); // mixed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Object[] alloc1M() {
|
||||||
|
Object[] ret = new Object[1024];
|
||||||
|
// Alloc 1024 1k byte arrays (~1M)
|
||||||
|
for (int i = 0; i < ret.length; i++) {
|
||||||
|
ret[i] = new byte[1024];
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void partialFree(Object[] array) {
|
||||||
|
// Free every other element
|
||||||
|
for (int i = 0; i < array.length; i+=2) {
|
||||||
|
array[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user