1 /* 2 * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 /* 25 * @test TestHeapUncommit 26 * @summary Acceptance tests: collector can withstand allocation 27 * @key gc 28 * 29 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 30 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 31 * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify 32 * TestHeapUncommit 33 * 34 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 35 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 36 * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify 37 * TestHeapUncommit 38 * 39 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 40 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 41 * -XX:+ShenandoahDegeneratedGC 42 * TestHeapUncommit 43 * 44 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 45 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 46 * -XX:-ShenandoahDegeneratedGC 47 * TestHeapUncommit 48 */ 49 50 /* 51 * @test TestHeapUncommit 52 * @summary Acceptance tests: collector can withstand allocation 53 * @key gc 54 * 55 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 56 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 57 * -XX:+ShenandoahVerify 58 * TestHeapUncommit 59 * 60 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 61 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 62 * TestHeapUncommit 63 * 64 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 65 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static 66 * TestHeapUncommit 67 * 68 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 69 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact 70 * TestHeapUncommit 71 * 72 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 73 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 74 * TestHeapUncommit 75 * 76 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 77 * -XX:+UseShenandoahGC 78 * -XX:-UseTLAB -XX:+ShenandoahVerify 79 * TestHeapUncommit 80 */ 81 82 /* 83 * @test TestHeapUncommit 84 * @summary Acceptance tests: collector can withstand allocation 85 * @key gc 86 * 87 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 88 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu 89 * -XX:+ShenandoahVerify 90 * TestHeapUncommit 91 * 92 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 93 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu 94 * TestHeapUncommit 95 * 96 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 97 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 98 * TestHeapUncommit 99 */ 100 101 /* 102 * @test TestHeapUncommit 103 * @key gc 104 * @requires (vm.bits == "64") 105 * 106 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 -XX:+UseLargePages 107 * -XX:+UseShenandoahGC 108 * -XX:+ShenandoahVerify 109 * TestHeapUncommit 110 * 111 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 -XX:+UseLargePages 112 * -XX:+UseShenandoahGC 113 * TestHeapUncommit 114 * 115 * @run main/othervm -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahUncommit -XX:ShenandoahUncommitDelay=0 -XX:+UseLargePages 116 * -XX:+UseShenandoahGC 117 * -XX:-UseTLAB -XX:+ShenandoahVerify 118 * TestHeapUncommit 119 */ 120 121 import java.util.Random; 122 123 public class TestHeapUncommit { 124 125 static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation 126 127 static volatile Object sink; 128 129 public static void main(String[] args) throws Exception { 130 final int min = 0; 131 final int max = 384 * 1024; 132 long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2)); 133 134 Random r = new Random(); 135 for (long c = 0; c < count; c++) { 136 sink = new int[min + r.nextInt(max - min)]; 137 } 138 } 139 140 }