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