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