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