1 /*
   2  * Copyright (c) 2016, 2018, Red Hat, Inc. All rights reserved.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 /*
  25  * @test TestAllocIntArrays
  26  * @summary Acceptance tests: collector can withstand allocation
  27  * @key gc
  28  *
  29  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
  30  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  31  *      -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify
  32  *      TestAllocIntArrays
  33  *
  34  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
  35  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  36  *      -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify
  37  *      TestAllocIntArrays
  38  *
  39  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
  40  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  41  *      -XX:+ShenandoahDegeneratedGC
  42  *      TestAllocIntArrays
  43  *
  44  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
  45  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  46  *      -XX:-ShenandoahDegeneratedGC
  47  *      TestAllocIntArrays
  48  */
  49 
  50 /*
  51  * @test TestAllocIntArrays
  52  * @summary Acceptance tests: collector can withstand allocation
  53  * @key gc
  54  *
  55  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
  56  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  57  *      -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify
  58  *      TestAllocIntArrays
  59  *
  60  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
  61  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  62  *      -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify
  63  *      TestAllocIntArrays
  64  *
  65  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
  66  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  67  *      -XX:+ShenandoahOOMDuringEvacALot
  68  *      TestAllocIntArrays
  69  *
  70  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
  71  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  72  *      -XX:+ShenandoahAllocFailureALot
  73  *      TestAllocIntArrays
  74  *
  75  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
  76  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  77  *      TestAllocIntArrays
  78  */
  79 
  80 /*
  81  * @test TestAllocIntArrays
  82  * @summary Acceptance tests: collector can withstand allocation
  83  * @key gc
  84  *
  85  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
  86  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
  87  *      -XX:+ShenandoahVerify
  88  *      TestAllocIntArrays
  89  *
  90  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
  91  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
  92  *      TestAllocIntArrays
  93  */
  94 
  95 /*
  96  * @test TestAllocIntArrays
  97  * @summary Acceptance tests: collector can withstand allocation
  98  * @key gc
  99  *
 100  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 101  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
 102  *      TestAllocIntArrays
 103  */
 104 
 105 /*
 106  * @test TestAllocIntArrays
 107  * @summary Acceptance tests: collector can withstand allocation
 108  * @key gc
 109  *
 110  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 111  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
 112  *      TestAllocIntArrays
 113  */
 114 
 115 /*
 116  * @test TestAllocIntArrays
 117  * @summary Acceptance tests: collector can withstand allocation
 118  * @key gc
 119  *
 120  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 121  *      -XX:+UseShenandoahGC
 122  *      -XX:-UseTLAB -XX:+ShenandoahVerify
 123  *      TestAllocIntArrays
 124  */
 125 
 126 /*
 127  * @test TestAllocIntArrays
 128  * @summary Acceptance tests: collector can withstand allocation
 129  * @key gc
 130  *
 131  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 132  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 133  *      -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify
 134  *      TestAllocIntArrays
 135  *
 136  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 137  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 138  *      -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify
 139  *      TestAllocIntArrays
 140  *
 141  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 142  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 143  *      -XX:+ShenandoahOOMDuringEvacALot
 144  *      TestAllocIntArrays
 145  *
 146  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 147  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 148  *      -XX:+ShenandoahAllocFailureALot
 149  *      TestAllocIntArrays
 150  *
 151  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 152  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 153  *      TestAllocIntArrays
 154  */
 155 
 156 /*
 157  * @test TestAllocIntArrays
 158  * @summary Acceptance tests: collector can withstand allocation
 159  * @key gc
 160  *
 161  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 162  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
 163  *      -XX:+ShenandoahVerify
 164  *      TestAllocIntArrays
 165  *
 166  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 167  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
 168  *      TestAllocIntArrays
 169  */
 170 
 171 import java.util.Random;
 172 
 173 public class TestAllocIntArrays {
 174 
 175     static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
 176 
 177     static volatile Object sink;
 178 
 179     public static void main(String[] args) throws Exception {
 180         final int min = 0;
 181         final int max = 384 * 1024;
 182         long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2));
 183 
 184         Random r = new Random();
 185         for (long c = 0; c < count; c++) {
 186             sink = new int[min + r.nextInt(max - min)];
 187         }
 188     }
 189 
 190 }