1 /*
2 * Copyright (c) 2016, 2018, Red Hat, Inc. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
82 * TestAllocObjectArrays
83 */
84
85 /*
86 * @test id=adaptive
87 * @summary Acceptance tests: collector can withstand allocation
88 * @key randomness
89 * @requires vm.gc.Shenandoah
90 * @library /test/lib
91 *
92 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
93 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
94 * -XX:+ShenandoahVerify
95 * TestAllocObjectArrays
96 *
97 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
98 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
99 * TestAllocObjectArrays
100 */
101
102 /*
103 * @test id=static
104 * @summary Acceptance tests: collector can withstand allocation
105 * @key randomness
106 * @requires vm.gc.Shenandoah
107 * @library /test/lib
108 *
109 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
110 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
111 * TestAllocObjectArrays
112 */
113
114 /*
115 * @test id=compact
116 * @summary Acceptance tests: collector can withstand allocation
117 * @key randomness
118 * @requires vm.gc.Shenandoah
119 * @library /test/lib
120 *
121 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
122 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
123 * TestAllocObjectArrays
124 */
125
126 /*
127 * @test id=no-tlab
128 * @summary Acceptance tests: collector can withstand allocation
129 * @key randomness
130 * @requires vm.gc.Shenandoah
131 * @library /test/lib
132 *
133 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
134 * -XX:+UseShenandoahGC
135 * -XX:-UseTLAB -XX:+ShenandoahVerify
136 * TestAllocObjectArrays
137 */
138 import java.util.Random;
139 import jdk.test.lib.Utils;
140
141 public class TestAllocObjectArrays {
142
143 static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
144
145 static volatile Object sink;
146
147 public static void main(String[] args) throws Exception {
148 final int min = 0;
149 final int max = 384 * 1024;
150 long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2));
151
152 Random r = Utils.getRandomInstance();
153 for (long c = 0; c < count; c++) {
154 sink = new Object[min + r.nextInt(max - min)];
155 }
156 }
|
1 /*
2 * Copyright (c) 2016, 2018, Red Hat, Inc. All rights reserved.
3 * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
83 * TestAllocObjectArrays
84 */
85
86 /*
87 * @test id=adaptive
88 * @summary Acceptance tests: collector can withstand allocation
89 * @key randomness
90 * @requires vm.gc.Shenandoah
91 * @library /test/lib
92 *
93 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
94 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
95 * -XX:+ShenandoahVerify
96 * TestAllocObjectArrays
97 *
98 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
99 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
100 * TestAllocObjectArrays
101 */
102
103 /*
104 * @test id=generational
105 * @summary Acceptance tests: collector can withstand allocation
106 * @key randomness
107 * @requires vm.gc.Shenandoah
108 * @library /test/lib
109 *
110 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
111 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
112 * -XX:+ShenandoahVerify
113 * TestAllocObjectArrays
114 *
115 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
116 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
117 * -XX:+ShenandoahOOMDuringEvacALot
118 * -XX:+ShenandoahVerify
119 * TestAllocObjectArrays
120 *
121 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
122 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
123 * -XX:+ShenandoahAllocFailureALot
124 * -XX:+ShenandoahVerify
125 * TestAllocObjectArrays
126 *
127 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
128 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
129 * TestAllocObjectArrays
130 */
131
132 /*
133 * @test id=static
134 * @summary Acceptance tests: collector can withstand allocation
135 * @key randomness
136 * @requires vm.gc.Shenandoah
137 * @library /test/lib
138 *
139 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
140 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
141 * TestAllocObjectArrays
142 */
143
144 /*
145 * @test id=compact
146 * @summary Acceptance tests: collector can withstand allocation
147 * @key randomness
148 * @requires vm.gc.Shenandoah
149 * @library /test/lib
150 *
151 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
152 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
153 * TestAllocObjectArrays
154 */
155
156 /*
157 * @test id=no-tlab
158 * @summary Acceptance tests: collector can withstand allocation
159 * @key randomness
160 * @requires vm.gc.Shenandoah
161 * @library /test/lib
162 *
163 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
164 * -XX:+UseShenandoahGC
165 * -XX:-UseTLAB -XX:+ShenandoahVerify
166 * TestAllocObjectArrays
167 *
168 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
169 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
170 * -XX:-UseTLAB -XX:+ShenandoahVerify
171 * TestAllocObjectArrays
172 */
173 import java.util.Random;
174 import jdk.test.lib.Utils;
175
176 public class TestAllocObjectArrays {
177
178 static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
179
180 static volatile Object sink;
181
182 public static void main(String[] args) throws Exception {
183 final int min = 0;
184 final int max = 384 * 1024;
185 long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2));
186
187 Random r = Utils.getRandomInstance();
188 for (long c = 0; c < count; c++) {
189 sink = new Object[min + r.nextInt(max - min)];
190 }
191 }
|