< prev index next >

test/hotspot/jtreg/gc/shenandoah/TestAllocIntArrays.java

Print this page

  1 /*
  2  * Copyright (c) 2016, 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  *

 80  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 81  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 82  *      TestAllocIntArrays
 83  */
 84 
 85 /*
 86  * @test id=adaptive
 87  * @summary Acceptance tests: collector can withstand allocation
 88  * @key randomness
 89  * @requires vm.gc.Shenandoah
 90  * @library /test/lib
 91  *
 92  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 93  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
 94  *      -XX:+ShenandoahVerify
 95  *      TestAllocIntArrays
 96  *
 97  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 98  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
 99  *      TestAllocIntArrays









100  */
101 
102 /*
103  * @test id=static
104  * @summary Acceptance tests: collector can withstand allocation
105  * @key randomness
106  * @requires vm.gc.Shenandoah
107  * @library /test/lib
108  *
109  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
110  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
111  *      TestAllocIntArrays
112  */
113 
114 /*
115  * @test id=compact
116  * @summary Acceptance tests: collector can withstand allocation
117  * @key randomness
118  * @requires vm.gc.Shenandoah
119  * @library /test/lib

180  *      -XX:+ShenandoahVerify
181  *      TestAllocIntArrays
182  *
183  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
184  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
185  *      TestAllocIntArrays
186  */
187 
188 import java.util.Random;
189 import jdk.test.lib.Utils;
190 
191 public class TestAllocIntArrays {
192 
193     static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
194 
195     static volatile Object sink;
196 
197     public static void main(String[] args) throws Exception {
198         final int min = 0;
199         final int max = 384 * 1024;


200         long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2));
201 
202         Random r = Utils.getRandomInstance();



203         for (long c = 0; c < count; c++) {
204             sink = new int[min + r.nextInt(max - min)];
205         }
206     }
207 
208 }

  1 /*
  2  * Copyright (c) 2016, 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  *

 81  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 82  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 83  *      TestAllocIntArrays
 84  */
 85 
 86 /*
 87  * @test id=adaptive
 88  * @summary Acceptance tests: collector can withstand allocation
 89  * @key randomness
 90  * @requires vm.gc.Shenandoah
 91  * @library /test/lib
 92  *
 93  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 94  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
 95  *      -XX:+ShenandoahVerify
 96  *      TestAllocIntArrays
 97  *
 98  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
 99  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
100  *      TestAllocIntArrays
101  *
102  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
103  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
104  *      -XX:+ShenandoahVerify
105  *      TestAllocIntArrays
106  *
107  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
108  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational
109  *      TestAllocIntArrays
110  */
111 
112 /*
113  * @test id=static
114  * @summary Acceptance tests: collector can withstand allocation
115  * @key randomness
116  * @requires vm.gc.Shenandoah
117  * @library /test/lib
118  *
119  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
120  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
121  *      TestAllocIntArrays
122  */
123 
124 /*
125  * @test id=compact
126  * @summary Acceptance tests: collector can withstand allocation
127  * @key randomness
128  * @requires vm.gc.Shenandoah
129  * @library /test/lib

190  *      -XX:+ShenandoahVerify
191  *      TestAllocIntArrays
192  *
193  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
194  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
195  *      TestAllocIntArrays
196  */
197 
198 import java.util.Random;
199 import jdk.test.lib.Utils;
200 
201 public class TestAllocIntArrays {
202 
203     static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
204 
205     static volatile Object sink;
206 
207     public static void main(String[] args) throws Exception {
208         final int min = 0;
209         final int max = 384 * 1024;
210         // Each allocated int array is assumed to consume 16 bytes for alignment and header, plus
211         //  an average of 4 * the average number of elements in the array.
212         long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2));
213 
214         Random r = Utils.getRandomInstance();
215         // Repeatedly, allocate an array of int having between 0 and 384K elements, until we have
216         // allocated approximately TARGET_MB.  The largest allocated array consumes 384K*4 + 16, which is 1.5 M,
217         // which is well below the heap size of 1g.
218         for (long c = 0; c < count; c++) {
219             sink = new int[min + r.nextInt(max - min)];
220         }
221     }
222 
223 }
< prev index next >