author | pliden |
Tue, 26 Nov 2019 11:57:58 +0100 | |
changeset 59267 | 4444591b3ac0 |
parent 59149 | 3b998574be4b |
permissions | -rw-r--r-- |
59149 | 1 |
/* |
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. 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 |
package gc.z; |
|
25 |
||
26 |
/* |
|
27 |
* @test TestSmallHeap |
|
59267
4444591b3ac0
8234619: ZGC: gc/z/TestSmallHeap.java failure with Out Of Memory
pliden
parents:
59149
diff
changeset
|
28 |
* @requires vm.gc.Z & !vm.graal.enabled & vm.compMode != "Xcomp" |
59149 | 29 |
* @summary Test ZGC with small heaps |
30 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xlog:gc,gc+init,gc+heap -Xmx8M gc.z.TestSmallHeap |
|
31 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xlog:gc,gc+init,gc+heap -Xmx16M gc.z.TestSmallHeap |
|
32 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xlog:gc,gc+init,gc+heap -Xmx32M gc.z.TestSmallHeap |
|
33 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xlog:gc,gc+init,gc+heap -Xmx64M gc.z.TestSmallHeap |
|
34 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xlog:gc,gc+init,gc+heap -Xmx128M gc.z.TestSmallHeap |
|
35 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xlog:gc,gc+init,gc+heap -Xmx256M gc.z.TestSmallHeap |
|
36 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xlog:gc,gc+init,gc+heap -Xmx512M gc.z.TestSmallHeap |
|
37 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xlog:gc,gc+init,gc+heap -Xmx1024M gc.z.TestSmallHeap |
|
38 |
*/ |
|
39 |
||
40 |
import java.lang.ref.Reference; |
|
41 |
||
42 |
public class TestSmallHeap { |
|
43 |
public static void main(String[] args) throws Exception { |
|
44 |
final long maxCapacity = Runtime.getRuntime().maxMemory(); |
|
45 |
System.out.println("Max Capacity " + maxCapacity + " bytes"); |
|
46 |
||
47 |
// Allocate byte arrays of increasing length, so that |
|
48 |
// all allocaion paths (small/medium/large) are tested. |
|
49 |
for (int length = 16; length <= maxCapacity / 16; length *= 2) { |
|
50 |
System.out.println("Allocating " + length + " bytes"); |
|
51 |
Reference.reachabilityFence(new byte[length]); |
|
52 |
} |
|
53 |
||
54 |
System.out.println("Success"); |
|
55 |
} |
|
56 |
} |