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 withstand allocation 29 * @key randomness 30 * @requires vm.gc.Shenandoah 31 * @library /test/lib 32 * 33 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 34 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 35 * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify 36 * TestHeapUncommit 37 * 38 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 39 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 40 * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify 41 * TestHeapUncommit 42 * 43 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 44 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 45 * -XX:+ShenandoahDegeneratedGC 46 * TestHeapUncommit 47 * 48 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 49 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 50 * -XX:-ShenandoahDegeneratedGC 51 * TestHeapUncommit 52 */ 53 54 /* 55 * @test id=adaptive 56 * @summary Acceptance tests: collector can withstand allocation 57 * @key randomness 58 * @requires vm.gc.Shenandoah 59 * @library /test/lib 60 * 61 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 62 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 63 * -XX:+ShenandoahVerify 64 * TestHeapUncommit 65 * 66 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 67 * -XX:+UseShenandoahGC 68 * -XX:-UseTLAB -XX:+ShenandoahVerify 69 * TestHeapUncommit 70 * 71 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 72 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 73 * TestHeapUncommit 74 * 75 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 76 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static 77 * TestHeapUncommit 78 * 79 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 80 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact 81 * TestHeapUncommit 82 * 83 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 84 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 85 * TestHeapUncommit 86 */ 87 88 /* 89 * @test id=generational 90 * @summary Acceptance tests: collector can withstand allocation 91 * @key randomness 92 * @requires vm.gc.Shenandoah 93 * @library /test/lib 94 * 95 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 96 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational 97 * -XX:+ShenandoahVerify 98 * TestHeapUncommit 99 * 100 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 101 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational 102 * -XX:-UseTLAB -XX:+ShenandoahVerify 103 * TestHeapUncommit 104 * 105 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 106 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational 107 * TestHeapUncommit 108 */ 109 110 /* 111 * @test id=iu 112 * @summary Acceptance tests: collector can withstand allocation 113 * @key randomness 114 * @requires vm.gc.Shenandoah 115 * @library /test/lib 116 * 117 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 118 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu 119 * -XX:+ShenandoahVerify 120 * TestHeapUncommit 121 * 122 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 123 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu 124 * TestHeapUncommit 125 * 126 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 127 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 128 * TestHeapUncommit 129 */ 130 131 /* 132 * @test id=default-lp 133 * @key randomness 134 * @requires vm.gc.Shenandoah 135 * @requires vm.bits == "64" 136 * @library /test/lib 137 * 138 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 -XX:+UseLargePages 139 * -XX:+UseShenandoahGC 140 * -XX:+ShenandoahVerify 141 * TestHeapUncommit 142 * 143 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 -XX:+UseLargePages 144 * -XX:+UseShenandoahGC 145 * -XX:-UseTLAB -XX:+ShenandoahVerify 146 * TestHeapUncommit 147 * 148 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 -XX:+UseLargePages 149 * -XX:+UseShenandoahGC 150 * TestHeapUncommit 151 */ 152 153 import java.util.Random; 154 import jdk.test.lib.Utils; 155 156 public class TestHeapUncommit { 157 158 static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation 159 160 static volatile Object sink; 161 162 public static void main(String[] args) throws Exception { 163 final int min = 0; 164 final int max = 384 * 1024; 165 long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2)); 166 167 Random r = Utils.getRandomInstance(); 168 for (long c = 0; c < count; c++) { 169 sink = new int[min + r.nextInt(max - min)]; 170 } 171 } 172 173 }