1 /*
  2  * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
  3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 /*
 27  * @test id=passive
 28  * @summary Acceptance tests: collector can deal with retained objects
 29  * @requires vm.gc.Shenandoah
 30  *
 31  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 32  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
 33  *      -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify
 34  *      TestRetainObjects
 35  *
 36  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 37  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
 38  *      -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify
 39  *      TestRetainObjects
 40  *
 41  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 42  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
 43  *      -XX:+ShenandoahDegeneratedGC
 44  *      TestRetainObjects
 45  *
 46  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 47  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
 48  *      -XX:-ShenandoahDegeneratedGC
 49  *      TestRetainObjects
 50  */
 51 
 52 /*
 53  * @test id=aggressive
 54  * @summary Acceptance tests: collector can deal with retained objects
 55  * @requires vm.gc.Shenandoah
 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 
 72 /*
 73  * @test id=adaptive
 74  * @summary Acceptance tests: collector can deal with retained objects
 75  * @requires vm.gc.Shenandoah
 76  *
 77  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 78  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
 79  *      -XX:+ShenandoahVerify
 80  *      TestRetainObjects
 81  *
 82  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 83  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
 84  *      TestRetainObjects
 85  */
 86 
 87 /*
 88  * @test id=generational
 89  * @summary Acceptance tests: collector can deal with retained objects
 90  * @requires vm.gc.Shenandoah
 91  *
 92  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 93  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
 94  *      -XX:+ShenandoahVerify
 95  *      TestRetainObjects
 96  *
 97  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 98  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
 99  *      -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify
100  *      TestRetainObjects
101  *
102  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
103  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
104  *      -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify
105  *      TestRetainObjects
106  *
107  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
108  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
109  *      TestRetainObjects
110  */
111 
112 /*
113  * @test id=static
114  * @summary Acceptance tests: collector can deal with retained objects
115  * @requires vm.gc.Shenandoah
116  *
117  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
118  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
119  *      TestRetainObjects
120  */
121 
122 /*
123  * @test id=compact
124  * @summary Acceptance tests: collector can deal with retained objects
125  * @requires vm.gc.Shenandoah
126  *
127  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
128  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
129  *      TestRetainObjects
130  */
131 
132 /*
133  * @test id=no-tlab
134  * @summary Acceptance tests: collector can deal with retained objects
135  * @requires vm.gc.Shenandoah
136  *
137  * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
138  *      -XX:+UseShenandoahGC
139  *      -XX:-UseTLAB -XX:+ShenandoahVerify
140  *      TestRetainObjects
141  */
142 
143 public class TestRetainObjects {
144 
145     static final int COUNT = 10_000_000;
146     static final int WINDOW = 10_000;
147 
148     static final String[] reachable = new String[WINDOW];
149 
150     public static void main(String[] args) throws Exception {
151         int rIdx = 0;
152         for (int c = 0; c < COUNT; c++) {
153             reachable[rIdx] = ("LargeString" + c);
154             rIdx++;
155             if (rIdx >= WINDOW) {
156                 rIdx = 0;
157             }
158         }
159     }
160 
161 }