Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java
41153 views
1
/*
2
* Copyright (c) 2017, 2020, 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
import java.io.File;
25
import java.util.stream.Collectors;
26
27
import jdk.test.lib.apps.LingeredApp;
28
import jdk.test.lib.JDKToolLauncher;
29
import jdk.test.lib.process.ProcessTools;
30
import jdk.test.lib.process.OutputAnalyzer;
31
import jdk.test.lib.SA.SATestUtils;
32
import jdk.test.lib.Utils;
33
34
/**
35
* @test
36
* @library /test/lib
37
* @bug 8171084
38
* @requires vm.hasSA & (vm.bits == "64" & os.maxMemory > 8g)
39
* @modules java.base/jdk.internal.misc
40
* jdk.hotspot.agent/sun.jvm.hotspot
41
* jdk.hotspot.agent/sun.jvm.hotspot.utilities
42
* jdk.hotspot.agent/sun.jvm.hotspot.oops
43
* jdk.hotspot.agent/sun.jvm.hotspot.debugger
44
* @run main/timeout=1800/othervm -Xmx8g TestHeapDumpForLargeArray
45
*/
46
47
public class TestHeapDumpForLargeArray {
48
49
private static LingeredAppWithLargeArray theApp = null;
50
51
private static void attachAndDump(String heapDumpFileName,
52
long lingeredAppPid) throws Exception {
53
54
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
55
launcher.addToolArg("jmap");
56
launcher.addToolArg("--binaryheap");
57
launcher.addToolArg("--dumpfile");
58
launcher.addToolArg(heapDumpFileName);
59
launcher.addToolArg("--pid");
60
launcher.addToolArg(Long.toString(lingeredAppPid));
61
62
ProcessBuilder processBuilder = SATestUtils.createProcessBuilder(launcher);
63
System.out.println(
64
processBuilder.command().stream().collect(Collectors.joining(" ")));
65
66
OutputAnalyzer SAOutput = ProcessTools.executeProcess(processBuilder);
67
SAOutput.shouldHaveExitValue(0);
68
SAOutput.shouldNotContain("Heap segment size overflow");
69
SAOutput.shouldContain("truncating to");
70
SAOutput.shouldContain("heap written to");
71
SAOutput.shouldContain(heapDumpFileName);
72
System.out.println(SAOutput.getOutput());
73
74
}
75
76
public static void main (String... args) throws Exception {
77
SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work.
78
79
String heapDumpFileName = "LargeArrayHeapDump.bin";
80
81
File heapDumpFile = new File(heapDumpFileName);
82
if (heapDumpFile.exists()) {
83
heapDumpFile.delete();
84
}
85
86
try {
87
// Need to add the default arguments first to have explicit
88
// -Xmx8g last, otherwise test will fail if default
89
// arguments contain a smaller -Xmx.
90
String[] vmArgs = Utils.prependTestJavaOpts(
91
"-XX:+UsePerfData",
92
"-Xmx8g");
93
94
theApp = new LingeredAppWithLargeArray();
95
LingeredApp.startAppExactJvmOpts(theApp, vmArgs);
96
attachAndDump(heapDumpFileName, theApp.getPid());
97
} finally {
98
LingeredApp.stopApp(theApp);
99
heapDumpFile.delete();
100
}
101
}
102
}
103
104