Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/TestDynamicSoftMaxHeapSize.java
32284 views
1
/*
2
* Copyright (c) 2020, 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 TestDynamicSoftMaxHeapSize
27
* @library /testlibrary
28
*
29
* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
30
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
31
* -XX:+ShenandoahDegeneratedGC
32
* -Dtarget=10000
33
* TestDynamicSoftMaxHeapSize
34
*
35
* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
36
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
37
* -XX:-ShenandoahDegeneratedGC
38
* -Dtarget=10000
39
* TestDynamicSoftMaxHeapSize
40
*/
41
42
/*
43
* @test TestDynamicSoftMaxHeapSize
44
* @library /testlibrary
45
*
46
* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
47
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
48
* -Dtarget=1000
49
* TestDynamicSoftMaxHeapSize
50
*/
51
52
/*
53
* @test TestDynamicSoftMaxHeapSize
54
* @library /testlibrary
55
*
56
* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
57
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
58
* -Dtarget=10000
59
* TestDynamicSoftMaxHeapSize
60
*/
61
62
/*
63
* @test TestDynamicSoftMaxHeapSize
64
* @library /testlibrary
65
*
66
* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
67
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
68
* -Dtarget=10000
69
* TestDynamicSoftMaxHeapSize
70
*/
71
72
/*
73
* @test TestDynamicSoftMaxHeapSize
74
* @library /testlibrary
75
*
76
* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
77
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
78
* -Dtarget=1000
79
* TestDynamicSoftMaxHeapSize
80
*/
81
82
/*
83
* @test TestDynamicSoftMaxHeapSize
84
* @library /testlibrary
85
*
86
* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
87
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
88
* -Dtarget=1000
89
* TestDynamicSoftMaxHeapSize
90
*/
91
92
/*
93
* @test TestDynamicSoftMaxHeapSize
94
* @library /testlibrary
95
*
96
* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
97
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
98
* -Dtarget=10000
99
* TestDynamicSoftMaxHeapSize
100
*/
101
102
import java.util.Random;
103
import com.oracle.java.testlibrary.*;
104
105
public class TestDynamicSoftMaxHeapSize {
106
107
static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
108
static final long STRIDE = 10_000_000;
109
110
static volatile Object sink;
111
112
public static void main(String[] args) throws Exception {
113
long count = TARGET_MB * 1024 * 1024 / 16;
114
Random r = new Random();
115
116
String pid = Integer.toString(ProcessTools.getProcessId());
117
ProcessBuilder pb = new ProcessBuilder();
118
119
for (long c = 0; c < count; c += STRIDE) {
120
// Sizes specifically include heaps below Xms and above Xmx to test saturation code.
121
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.set_flag", "ShenandoahSoftMaxHeapSize", "" + r.nextInt(768*1024*1024)});
122
pb.start().waitFor();
123
for (long s = 0; s < STRIDE; s++) {
124
sink = new Object();
125
}
126
Thread.sleep(1);
127
}
128
}
129
130
}
131
132