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 * @key randomness 30 * @requires vm.gc.Shenandoah 31 * @library /test/lib 32 * 33 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 34 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 35 * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify 36 * TestAllocIntArrays 37 * 38 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 39 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 40 * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify 41 * TestAllocIntArrays 42 * 43 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 44 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 45 * -XX:+ShenandoahDegeneratedGC 46 * TestAllocIntArrays 47 * 48 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 49 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 50 * -XX:-ShenandoahDegeneratedGC 51 * TestAllocIntArrays 52 */ 53 54 /* 55 * @test id=aggressive 56 * @summary Acceptance tests: collector can withstand allocation 57 * @key randomness 58 * @requires vm.gc.Shenandoah 59 * @library /test/lib 60 * 61 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 62 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 63 * -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify 64 * TestAllocIntArrays 65 * 66 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 67 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 68 * -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify 69 * TestAllocIntArrays 70 * 71 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 72 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 73 * -XX:+ShenandoahOOMDuringEvacALot 74 * TestAllocIntArrays 75 * 76 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 77 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 78 * -XX:+ShenandoahAllocFailureALot 79 * TestAllocIntArrays 80 * 81 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 82 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 83 * TestAllocIntArrays 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 * TestAllocIntArrays 97 */ 98 99 /* 100 * @test id=generational 101 * @summary Acceptance tests: collector can withstand allocation 102 * @key randomness 103 * @requires vm.gc.Shenandoah 104 * @library /test/lib 105 * 106 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 107 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 108 * TestAllocIntArrays 109 * 110 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 111 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational 112 * TestAllocIntArrays 113 */ 114 115 /* 116 * @test id=static 117 * @summary Acceptance tests: collector can withstand allocation 118 * @key randomness 119 * @requires vm.gc.Shenandoah 120 * @library /test/lib 121 * 122 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 123 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static 124 * TestAllocIntArrays 125 */ 126 127 /* 128 * @test id=compact 129 * @summary Acceptance tests: collector can withstand allocation 130 * @key randomness 131 * @requires vm.gc.Shenandoah 132 * @library /test/lib 133 * 134 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 135 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact 136 * TestAllocIntArrays 137 */ 138 139 /* 140 * @test id=no-tlab 141 * @summary Acceptance tests: collector can withstand allocation 142 * @key randomness 143 * @requires vm.gc.Shenandoah 144 * @library /test/lib 145 * 146 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 147 * -XX:+UseShenandoahGC 148 * -XX:-UseTLAB -XX:+ShenandoahVerify 149 * TestAllocIntArrays 150 */ 151 152 /* 153 * @test id=iu-aggressive 154 * @summary Acceptance tests: collector can withstand allocation 155 * @key randomness 156 * @requires vm.gc.Shenandoah 157 * @library /test/lib 158 * 159 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 160 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 161 * -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify 162 * TestAllocIntArrays 163 * 164 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 165 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 166 * -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify 167 * TestAllocIntArrays 168 * 169 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 170 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 171 * -XX:+ShenandoahOOMDuringEvacALot 172 * TestAllocIntArrays 173 * 174 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 175 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 176 * -XX:+ShenandoahAllocFailureALot 177 * TestAllocIntArrays 178 * 179 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 180 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 181 * TestAllocIntArrays 182 */ 183 184 /* 185 * @test id=iu 186 * @summary Acceptance tests: collector can withstand allocation 187 * @key randomness 188 * @requires vm.gc.Shenandoah 189 * @library /test/lib 190 * 191 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 192 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu 193 * -XX:+ShenandoahVerify 194 * TestAllocIntArrays 195 * 196 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g 197 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu 198 * TestAllocIntArrays 199 */ 200 201 import java.util.Random; 202 import jdk.test.lib.Utils; 203 204 public class TestAllocIntArrays { 205 206 static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation 207 208 static volatile Object sink; 209 210 public static void main(String[] args) throws Exception { 211 final int min = 0; 212 final int max = 384 * 1024; 213 // Each allocated int array is assumed to consume 16 bytes for alignment and header, plus 214 // an average of 4 * the average number of elements in the array. 215 long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2)); 216 217 Random r = Utils.getRandomInstance(); 218 // Repeatedly, allocate an array of int having between 0 and 384K elements, until we have 219 // allocated approximately TARGET_MB. The largest allocated array consumes 384K*4 + 16, which is 1.5 M, 220 // which is well below the heap size of 1g. 221 for (long c = 0; c < count; c++) { 222 sink = new int[min + r.nextInt(max - min)]; 223 } 224 } 225 226 }