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 TestRetainObjects
  26  * @summary Acceptance tests: collector can deal with retained objects
  27  * @key gc
  28  * @requires vm.gc.Shenandoah & !vm.graal.enabled
  29  *
  30  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  31  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  32  *      -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify
  33  *      TestRetainObjects
  34  *
  35  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  36  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  37  *      -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify
  38  *      TestRetainObjects
  39  *
  40  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  41  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  42  *      -XX:+ShenandoahDegeneratedGC
  43  *      TestRetainObjects
  44  *
  45  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  46  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  47  *      -XX:-ShenandoahDegeneratedGC
  48  *      TestRetainObjects
  49  */
  50 
  51 /*
  52  * @test TestRetainObjects
  53  * @summary Acceptance tests: collector can deal with retained objects
  54  * @key gc
  55  * @requires vm.gc.Shenandoah & !vm.graal.enabled
  56  *
  57  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  58  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  59  *      -XX:+ShenandoahOOMDuringEvacALot
  60  *      TestRetainObjects
  61  *
  62  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  63  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  64  *      -XX:+ShenandoahAllocFailureALot
  65  *      TestRetainObjects
  66  *
  67  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  68  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  69  *      TestRetainObjects
  70  *
  71  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  72  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
  73  *      -XX:+ShenandoahVerify
  74  *      TestRetainObjects
  75  *
  76  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  77  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
  78  *      TestRetainObjects
  79  *
  80  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  81  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
  82  *      TestRetainObjects
  83  *
  84  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  85  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
  86  *      TestRetainObjects
  87  *
  88  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  89  *      -XX:+UseShenandoahGC
  90  *      -XX:-UseTLAB -XX:+ShenandoahVerify
  91  *      TestRetainObjects
  92  */
  93 
  94 /*
  95  * @test TestRetainObjects
  96  * @summary Acceptance tests: collector can deal with retained objects
  97  * @key gc
  98  * @requires vm.gc.Shenandoah & !vm.graal.enabled
  99  *
 100  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 101  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal -XX:ShenandoahGCHeuristics=aggressive
 102  *      -XX:+ShenandoahOOMDuringEvacALot
 103  *      TestRetainObjects
 104  *
 105  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 106  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal -XX:ShenandoahGCHeuristics=aggressive
 107  *      -XX:+ShenandoahAllocFailureALot
 108  *      TestRetainObjects
 109  *
 110  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 111  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal -XX:ShenandoahGCHeuristics=aggressive
 112  *      TestRetainObjects
 113  *
 114  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 115  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal
 116  *      -XX:+ShenandoahVerify
 117  *      TestRetainObjects
 118  *
 119  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 120  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal
 121  *      TestRetainObjects
 122  */
 123 
 124 public class TestRetainObjects {
 125 
 126     static final int COUNT = 10_000_000;
 127     static final int WINDOW = 10_000;
 128 
 129     static final String[] reachable = new String[WINDOW];
 130 
 131     public static void main(String[] args) throws Exception {
 132         int rIdx = 0;
 133         for (int c = 0; c < COUNT; c++) {
 134             reachable[rIdx] = ("LargeString" + c);
 135             rIdx++;
 136             if (rIdx >= WINDOW) {
 137                 rIdx = 0;
 138             }
 139         }
 140     }
 141 
 142 }