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 TestAllocObjects
  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 TestAllocObjects
  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  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  81  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  82  *      -XX:+ShenandoahSuspendibleWorkers
  83  *      TestAllocObjects
  84  *
  85  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  86  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
  87  *      -XX:+ShenandoahVerify
  88  *      TestAllocObjects
  89  *
  90  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  91  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
  92  *      TestAllocObjects
  93  *
  94  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  95  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
  96  *      -XX:+ShenandoahSuspendibleWorkers
  97  *      TestAllocObjects
  98  *
  99  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 100  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
 101  *      TestAllocObjects
 102  *
 103  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 104  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
 105  *      -XX:+ShenandoahSuspendibleWorkers
 106  *      TestAllocObjects
 107  *
 108  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 109  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
 110  *      TestAllocObjects
 111  *
 112  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 113  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
 114  *      -XX:+ShenandoahSuspendibleWorkers
 115  *      TestAllocObjects
 116  */
 117 
 118 /*
 119  * @test TestAllocObjects
 120  * @summary Acceptance tests: collector can withstand allocation
 121  * @requires vm.gc.Shenandoah
 122  *
 123  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 124  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 125  *      -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify
 126  *      TestAllocObjects
 127  *
 128  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 129  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 130  *      -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify
 131  *      TestAllocObjects
 132  *
 133  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 134  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 135  *      -XX:+ShenandoahOOMDuringEvacALot
 136  *      TestAllocObjects
 137  *
 138  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 139  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 140  *      -XX:+ShenandoahAllocFailureALot
 141  *      TestAllocObjects
 142  *
 143  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 144  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 145  *      TestAllocObjects
 146  *
 147  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 148  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
 149  *      -XX:+ShenandoahVerify
 150  *      TestAllocObjects
 151  *
 152  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 153  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
 154  *      TestAllocObjects
 155  *
 156  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 157  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
 158  *      -XX:+ShenandoahSuspendibleWorkers
 159  *      TestAllocObjects
 160  */
 161 
 162 public class TestAllocObjects {
 163 
 164     static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
 165 
 166     static volatile Object sink;
 167 
 168     public static void main(String[] args) throws Exception {
 169         long count = TARGET_MB * 1024 * 1024 / 16;
 170         for (long c = 0; c < count; c++) {
 171             sink = new Object();
 172         }
 173     }
 174 
 175 }