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