Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/runtime/ErrorHandling/TestGZippedHeapDumpOnOutOfMemoryError.java
40942 views
1
/*
2
* Copyright (c) 2021 SAP SE. 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
* @test
26
* @summary Test verifies that -XX:HeapDumpGzipLevel=0 works
27
* @library /test/lib
28
* @run driver/timeout=240 TestGZippedHeapDumpOnOutOfMemoryError run 0
29
*/
30
31
/*
32
* @test
33
* @summary Test verifies that -XX:HeapDumpGzipLevel=1 works
34
* @library /test/lib
35
* @run driver/timeout=240 TestGZippedHeapDumpOnOutOfMemoryError run 1
36
*/
37
38
import jdk.test.lib.Asserts;
39
import jdk.test.lib.hprof.HprofParser;
40
import jdk.test.lib.process.ProcessTools;
41
import jdk.test.lib.process.OutputAnalyzer;
42
43
import java.io.File;
44
45
public class TestGZippedHeapDumpOnOutOfMemoryError {
46
47
static volatile Object[] oa;
48
49
public static void main(String[] args) throws Exception {
50
if (args.length == 2) {
51
test(Integer.parseInt(args[1]));
52
return;
53
}
54
55
try {
56
oa = new Object[Integer.MAX_VALUE];
57
throw new Error("OOME not triggered");
58
} catch (OutOfMemoryError err) {
59
// Ignore
60
}
61
}
62
63
static void test(int level) throws Exception {
64
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
65
"-XX:+HeapDumpOnOutOfMemoryError",
66
"-XX:HeapDumpGzipLevel=" + level,
67
"-Xmx128M",
68
TestGZippedHeapDumpOnOutOfMemoryError.class.getName());
69
70
Process proc = pb.start();
71
String heapdumpFilename = "java_pid" + proc.pid() + ".hprof" + (level > 0 ? ".gz" : "");
72
OutputAnalyzer output = new OutputAnalyzer(proc);
73
output.stdoutShouldNotBeEmpty();
74
output.shouldContain("Dumping heap to " + heapdumpFilename);
75
File dump = new File(heapdumpFilename);
76
Asserts.assertTrue(dump.exists() && dump.isFile(),
77
"Could not find dump file " + dump.getAbsolutePath());
78
79
HprofParser.parse(new File(heapdumpFilename));
80
System.out.println("PASSED");
81
}
82
83
}
84
85