1 /*
   2  * Copyright (c) 2017, 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 TestRegionSampling
  26  * @requires vm.gc.Shenandoah & !vm.graal.enabled
  27  *
  28  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahRegionSampling
  29  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  30  *      -XX:+ShenandoahDegeneratedGC
  31  *      TestRegionSampling
  32  *
  33  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahRegionSampling
  34  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  35  *      -XX:-ShenandoahDegeneratedGC
  36  *      TestRegionSampling
  37  */
  38 
  39 /*
  40  * @test TestRegionSampling
  41  * @requires vm.gc.Shenandoah & !vm.graal.enabled
  42  *
  43  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahRegionSampling
  44  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
  45  *      TestRegionSampling
  46  *
  47  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahRegionSampling
  48  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
  49  *      TestRegionSampling
  50  *
  51  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahRegionSampling
  52  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
  53  *      TestRegionSampling
  54  *
  55  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahRegionSampling
  56  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  57  *      TestRegionSampling
  58  */
  59 
  60 /*
  61  * @test TestRegionSampling
  62  * @requires vm.gc.Shenandoah & !vm.graal.enabled
  63  *
  64  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahRegionSampling
  65  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal -XX:ShenandoahGCHeuristics=aggressive
  66  *      TestRegionSampling
  67  *
  68  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahRegionSampling
  69  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal
  70  *      TestRegionSampling
  71  *
  72  */
  73 
  74 public class TestRegionSampling {
  75 
  76     static final long TARGET_MB = Long.getLong("target", 2_000); // 2 Gb allocation
  77 
  78     static volatile Object sink;
  79 
  80     public static void main(String[] args) throws Exception {
  81         long count = TARGET_MB * 1024 * 1024 / 16;
  82         for (long c = 0; c < count; c++) {
  83             sink = new Object();
  84         }
  85     }
  86 
  87 }