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  *
 24  */
 25 
 26 /*
 27  * @test id=passive
 28  * @summary Acceptance tests: collector can withstand allocation
 29  * @requires vm.gc.Shenandoah
 30  *
 31  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 32  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
 33  *      -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify
 34  *      TestAllocObjects
 35  *
 36  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 37  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
 38  *      -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify
 39  *      TestAllocObjects
 40  *
 41  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 42  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
 43  *      -XX:+ShenandoahDegeneratedGC
 44  *      TestAllocObjects
 45  *
 46  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 47  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
 48  *      -XX:-ShenandoahDegeneratedGC
 49  *      TestAllocObjects
 50  */
 51 
 52 /*
 53  * @test id=aggressive
 54  * @summary Acceptance tests: collector can withstand allocation
 55  * @requires vm.gc.Shenandoah
 56  *
 57  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 58  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 59  *      -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify
 60  *      TestAllocObjects
 61  *
 62  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 63  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 64  *      -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify
 65  *      TestAllocObjects
 66  *
 67  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 68  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 69  *      -XX:+ShenandoahOOMDuringEvacALot
 70  *      TestAllocObjects
 71  *
 72  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 73  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 74  *      -XX:+ShenandoahAllocFailureALot
 75  *      TestAllocObjects
 76  *
 77  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 78  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 79  *      TestAllocObjects
 80  */
 81 
 82 /*
 83  * @test id=adaptive
 84  * @summary Acceptance tests: collector can withstand allocation
 85  * @requires vm.gc.Shenandoah
 86  *
 87  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 88  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
 89  *      -XX:+ShenandoahVerify
 90  *      TestAllocObjects
 91  *
 92  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 93  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
 94  *      TestAllocObjects
 95  */
 96 
 97 /*
 98  * @test id=generational
 99  * @summary Acceptance tests: collector can withstand allocation
100  * @requires vm.gc.Shenandoah
101  *
102  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
103  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
104  *      -XX:+ShenandoahVerify
105  *      TestAllocObjects
106  *
107  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
108  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
109  *      TestAllocObjects
110  */
111 
112 /*
113  * @test id=static
114  * @summary Acceptance tests: collector can withstand allocation
115  * @requires vm.gc.Shenandoah
116  *
117  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
118  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
119  *      TestAllocObjects
120  */
121 
122 /*
123  * @test id=compact
124  * @summary Acceptance tests: collector can withstand allocation
125  * @requires vm.gc.Shenandoah
126  *
127  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
128  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
129  *      TestAllocObjects
130  */
131 
132 /*
133  * @test id=iu-aggressive
134  * @summary Acceptance tests: collector can withstand allocation
135  * @requires vm.gc.Shenandoah
136  *
137  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
138  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
139  *      -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify
140  *      TestAllocObjects
141  *
142  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
143  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
144  *      -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify
145  *      TestAllocObjects
146  *
147  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
148  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
149  *      -XX:+ShenandoahOOMDuringEvacALot
150  *      TestAllocObjects
151  *
152  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
153  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
154  *      -XX:+ShenandoahAllocFailureALot
155  *      TestAllocObjects
156  *
157  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
158  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
159  *      TestAllocObjects
160  */
161 
162 /*
163  * @test id=iu
164  * @summary Acceptance tests: collector can withstand allocation
165  * @requires vm.gc.Shenandoah
166  *
167  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
168  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
169  *      -XX:+ShenandoahVerify
170  *      TestAllocObjects
171  *
172  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
173  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
174  *      TestAllocObjects
175  */
176 
177 public class TestAllocObjects {
178 
179     static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
180 
181     static volatile Object sink;
182 
183     public static void main(String[] args) throws Exception {
184         long count = TARGET_MB * 1024 * 1024 / 16;
185         for (long c = 0; c < count; c++) {
186             sink = new Object();
187         }
188     }
189 
190 }