comparison test/gc/class_unloading/TestG1ClassUnloadingHWM.java @ 20524:85f4c4ecc963

8058475: TestCMSClassUnloadingEnabledHWM.java fails with '.*CMS Initial Mark.*' missing from stdout/stderr Reviewed-by: mgerdin, tschatzl, brutisso
author stefank
date Tue, 16 Sep 2014 10:13:45 +0200
parents 8a7429682242
children
comparison
equal deleted inserted replaced
20523:1b61c1b7b519 20524:85f4c4ecc963
24 /* 24 /*
25 * @test 25 * @test
26 * @key gc 26 * @key gc
27 * @bug 8049831 27 * @bug 8049831
28 * @library /testlibrary /testlibrary/whitebox 28 * @library /testlibrary /testlibrary/whitebox
29 * @build TestG1ClassUnloadingHWM AllocateBeyondMetaspaceSize 29 * @build TestG1ClassUnloadingHWM
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox 30 * @run main ClassFileInstaller sun.hotspot.WhiteBox
31 * @run driver TestG1ClassUnloadingHWM 31 * @run driver TestG1ClassUnloadingHWM
32 * @summary Test that -XX:-ClassUnloadingWithConcurrentMark will trigger a Full GC when more than MetaspaceSize metadata is allocated. 32 * @summary Test that -XX:-ClassUnloadingWithConcurrentMark will trigger a Full GC when more than MetaspaceSize metadata is allocated.
33 */ 33 */
34 34
35 import com.oracle.java.testlibrary.OutputAnalyzer; 35 import com.oracle.java.testlibrary.OutputAnalyzer;
36 import com.oracle.java.testlibrary.ProcessTools; 36 import com.oracle.java.testlibrary.ProcessTools;
37
38 import java.util.ArrayList; 37 import java.util.ArrayList;
39 import java.util.Arrays; 38 import java.util.Arrays;
39 import sun.hotspot.WhiteBox;
40 40
41 public class TestG1ClassUnloadingHWM { 41 public class TestG1ClassUnloadingHWM {
42 private static long MetaspaceSize = 32 * 1024 * 1024; 42 private static long MetaspaceSize = 32 * 1024 * 1024;
43 private static long YoungGenSize = 32 * 1024 * 1024; 43 private static long YoungGenSize = 32 * 1024 * 1024;
44 44
51 "-Xmn" + YoungGenSize, 51 "-Xmn" + YoungGenSize,
52 "-XX:+UseG1GC", 52 "-XX:+UseG1GC",
53 "-XX:" + (enableUnloading ? "+" : "-") + "ClassUnloadingWithConcurrentMark", 53 "-XX:" + (enableUnloading ? "+" : "-") + "ClassUnloadingWithConcurrentMark",
54 "-XX:+PrintHeapAtGC", 54 "-XX:+PrintHeapAtGC",
55 "-XX:+PrintGCDetails", 55 "-XX:+PrintGCDetails",
56 "AllocateBeyondMetaspaceSize", 56 TestG1ClassUnloadingHWM.AllocateBeyondMetaspaceSize.class.getName(),
57 "" + MetaspaceSize, 57 "" + MetaspaceSize,
58 "" + YoungGenSize); 58 "" + YoungGenSize);
59 return new OutputAnalyzer(pb.start()); 59 return new OutputAnalyzer(pb.start());
60 } 60 }
61 61
85 85
86 public static void main(String args[]) throws Exception { 86 public static void main(String args[]) throws Exception {
87 testWithG1ClassUnloading(); 87 testWithG1ClassUnloading();
88 testWithoutG1ClassUnloading(); 88 testWithoutG1ClassUnloading();
89 } 89 }
90
91 public static class AllocateBeyondMetaspaceSize {
92 public static Object dummy;
93
94 public static void main(String [] args) throws Exception {
95 if (args.length != 2) {
96 throw new IllegalArgumentException("Usage: <MetaspaceSize> <YoungGenSize>");
97 }
98
99 WhiteBox wb = WhiteBox.getWhiteBox();
100
101 // Allocate past the MetaspaceSize limit
102 long metaspaceSize = Long.parseLong(args[0]);
103 long allocationBeyondMetaspaceSize = metaspaceSize * 2;
104 long metaspace = wb.allocateMetaspace(null, allocationBeyondMetaspaceSize);
105
106 long youngGenSize = Long.parseLong(args[1]);
107 triggerYoungGCs(youngGenSize);
108
109 wb.freeMetaspace(null, metaspace, metaspace);
110 }
111
112 public static void triggerYoungGCs(long youngGenSize) {
113 long approxAllocSize = 32 * 1024;
114 long numAllocations = 2 * youngGenSize / approxAllocSize;
115
116 for (long i = 0; i < numAllocations; i++) {
117 dummy = new byte[(int)approxAllocSize];
118 }
119 }
120 }
90 } 121 }
91 122