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