20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test TestEagerReclaimHumongousRegions2
26 * @bug 8051973
27 * @summary Test to make sure that eager reclaim of humongous objects correctly clears
28 * mark bitmaps at reclaim.
29 * @key gc
30 * @library /testlibrary
31 */
32
33 import java.util.ArrayList;
34 import java.util.LinkedList;
35 import java.util.Random;
36
37 import com.oracle.java.testlibrary.OutputAnalyzer;
38 import com.oracle.java.testlibrary.ProcessTools;
39
40 class ObjectWithSomeRefs {
41 public ObjectWithSomeRefs other1;
42 public ObjectWithSomeRefs other2;
43 public ObjectWithSomeRefs other3;
44 public ObjectWithSomeRefs other4;
45 }
46
47 class ReclaimRegionFast {
48 public static final int M = 1024*1024;
49
50 public static LinkedList<Object> garbageList = new LinkedList<Object>();
51
52 public static void genGarbage(Object large) {
53 for (int i = 0; i < 64*1024; i++) {
54 Object[] garbage = new Object[50];
55 garbage[0] = large;
56 garbageList.add(garbage);
57 }
58 garbageList.clear();
59 }
89 large3 = new int[M - 20];
90 large4 = new int[M - 20];
91 genGarbage(large1);
92 // Make sure that the compiler cannot completely remove
93 // the allocation of the large object until here.
94 System.out.println(large1 + " " + large2 + " " + large3 + " " + large4);
95 }
96
97 // Keep the reference to the first object alive.
98 System.out.println(ref_from_stack);
99 }
100 }
101
102 public class TestEagerReclaimHumongousRegions2 {
103 public static void main(String[] args) throws Exception {
104 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
105 "-XX:+UseG1GC",
106 "-Xms128M",
107 "-Xmx128M",
108 "-Xmn2M",
109 "-XX:InitiatingHeapOccupancyPercent=0", // Want to have as much as possible initial marks.
110 "-XX:+PrintGC",
111 "-XX:+VerifyAfterGC",
112 "-XX:ConcGCThreads=1", // Want to make marking as slow as possible.
113 "-XX:+IgnoreUnrecognizedVMOptions", // G1VerifyBitmaps is develop only.
114 "-XX:+G1VerifyBitmaps",
115 ReclaimRegionFast.class.getName());
116 OutputAnalyzer output = new OutputAnalyzer(pb.start());
117 output.shouldHaveExitValue(0);
118 }
119 }
120
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test TestEagerReclaimHumongousRegions2
26 * @bug 8051973
27 * @summary Test to make sure that eager reclaim of humongous objects correctly clears
28 * mark bitmaps at reclaim.
29 * @key gc
30 * @library /testlibrary
31 */
32
33 import java.util.ArrayList;
34 import java.util.LinkedList;
35 import java.util.Random;
36
37 import com.oracle.java.testlibrary.OutputAnalyzer;
38 import com.oracle.java.testlibrary.ProcessTools;
39
40 // An object that has a few references to other instances to slow down marking.
41 class ObjectWithSomeRefs {
42 public ObjectWithSomeRefs other1;
43 public ObjectWithSomeRefs other2;
44 public ObjectWithSomeRefs other3;
45 public ObjectWithSomeRefs other4;
46 }
47
48 class ReclaimRegionFast {
49 public static final int M = 1024*1024;
50
51 public static LinkedList<Object> garbageList = new LinkedList<Object>();
52
53 public static void genGarbage(Object large) {
54 for (int i = 0; i < 64*1024; i++) {
55 Object[] garbage = new Object[50];
56 garbage[0] = large;
57 garbageList.add(garbage);
58 }
59 garbageList.clear();
60 }
90 large3 = new int[M - 20];
91 large4 = new int[M - 20];
92 genGarbage(large1);
93 // Make sure that the compiler cannot completely remove
94 // the allocation of the large object until here.
95 System.out.println(large1 + " " + large2 + " " + large3 + " " + large4);
96 }
97
98 // Keep the reference to the first object alive.
99 System.out.println(ref_from_stack);
100 }
101 }
102
103 public class TestEagerReclaimHumongousRegions2 {
104 public static void main(String[] args) throws Exception {
105 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
106 "-XX:+UseG1GC",
107 "-Xms128M",
108 "-Xmx128M",
109 "-Xmn2M",
110 "-XX:G1HeapRegionSize=1M",
111 "-XX:InitiatingHeapOccupancyPercent=0", // Want to have as much as possible initial marks.
112 "-XX:+PrintGC",
113 "-XX:+VerifyAfterGC",
114 "-XX:ConcGCThreads=1", // Want to make marking as slow as possible.
115 "-XX:+IgnoreUnrecognizedVMOptions", // G1VerifyBitmaps is develop only.
116 "-XX:+G1VerifyBitmaps",
117 ReclaimRegionFast.class.getName());
118 OutputAnalyzer output = new OutputAnalyzer(pb.start());
119 output.shouldHaveExitValue(0);
120 }
121 }
122
|