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 TestStringInternCleanup 27 * @summary Check that Shenandoah cleans up interned strings 28 * @key gc 29 * @requires vm.gc.Shenandoah & !vm.graal.enabled 30 * 31 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 32 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 33 * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify 34 * TestStringInternCleanup 35 * 36 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 37 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 38 * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify 39 * TestStringInternCleanup 40 * 41 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 42 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 43 * -XX:+ShenandoahDegeneratedGC 44 * TestStringInternCleanup 45 * 46 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 47 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 48 * -XX:-ShenandoahDegeneratedGC 49 * TestStringInternCleanup 50 */ 51 52 /* 53 * @test TestStringInternCleanup 54 * @summary Check that Shenandoah cleans up interned strings 55 * @key gc 56 * @requires vm.gc.Shenandoah & !vm.graal.enabled 57 * 58 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 59 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 60 * TestStringInternCleanup 61 * 62 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 63 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 64 * -XX:+ShenandoahVerify 65 * TestStringInternCleanup 66 * 67 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 68 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 69 * TestStringInternCleanup 70 * 71 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 72 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact 73 * TestStringInternCleanup 74 * 75 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:-ClassUnloadingWithConcurrentMark 76 * -XX:+UseShenandoahGC 77 * TestStringInternCleanup 78 */ 79 80 public class TestStringInternCleanup { 81 82 static final int COUNT = 1_000_000; 83 static final int WINDOW = 1_000; 84 85 static final String[] reachable = new String[WINDOW]; 86 87 public static void main(String[] args) throws Exception { 88 int rIdx = 0; 89 for (int c = 0; c < COUNT; c++) { 90 reachable[rIdx] = ("LargeInternedString" + c).intern(); 91 rIdx++; 92 if (rIdx >= WINDOW) { 93 rIdx = 0; 94 } 95 } 96 } 97 98 }