Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java
40942 views
1
/*
2
* Copyright (c) 2014, 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
package gc.g1;
25
26
/*
27
* @test TestG1TraceEagerReclaimHumongousObjects
28
* @bug 8058801 8048179
29
* @summary Ensure that the output for a G1TraceEagerReclaimHumongousObjects
30
* includes the expected necessary messages.
31
* @requires vm.gc.G1
32
* @library /test/lib
33
* @modules java.base/jdk.internal.misc
34
* java.management
35
* @run driver gc.g1.TestG1TraceEagerReclaimHumongousObjects
36
*/
37
38
import jdk.test.lib.process.OutputAnalyzer;
39
import jdk.test.lib.process.ProcessTools;
40
import java.util.LinkedList;
41
42
public class TestG1TraceEagerReclaimHumongousObjects {
43
public static void main(String[] args) throws Exception {
44
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
45
"-Xms128M",
46
"-Xmx128M",
47
"-Xmn16M",
48
"-XX:G1HeapRegionSize=1M",
49
"-Xlog:gc+phases=trace,gc+humongous=trace",
50
"-XX:+UnlockExperimentalVMOptions",
51
GCWithHumongousObjectTest.class.getName());
52
53
OutputAnalyzer output = new OutputAnalyzer(pb.start());
54
55
// As G1ReclaimDeadHumongousObjectsAtYoungGC is set(default), below logs should be displayed.
56
output.shouldContain("Humongous Reclaim");
57
output.shouldContain("Humongous Total");
58
output.shouldContain("Humongous Candidate");
59
output.shouldContain("Humongous Reclaimed");
60
61
// As G1TraceReclaimDeadHumongousObjectsAtYoungGC is set and GCWithHumongousObjectTest has humongous objects,
62
// these logs should be displayed.
63
output.shouldContain("Live humongous");
64
output.shouldContain("Dead humongous region");
65
output.shouldHaveExitValue(0);
66
}
67
68
static class GCWithHumongousObjectTest {
69
70
public static final int M = 1024*1024;
71
public static LinkedList<Object> garbageList = new LinkedList<Object>();
72
// A large object referenced by a static.
73
static int[] filler = new int[10 * M];
74
75
public static void genGarbage() {
76
for (int i = 0; i < 32*1024; i++) {
77
garbageList.add(new int[100]);
78
}
79
garbageList.clear();
80
}
81
82
public static void main(String[] args) {
83
84
int[] large = new int[M];
85
Object ref = large;
86
87
System.out.println("Creating garbage");
88
for (int i = 0; i < 100; i++) {
89
// A large object that will be reclaimed eagerly.
90
large = new int[6*M];
91
genGarbage();
92
// Make sure that the compiler cannot completely remove
93
// the allocation of the large object until here.
94
System.out.println(large);
95
}
96
97
// Keep the reference to the first object alive.
98
System.out.println(ref);
99
System.out.println("Done");
100
}
101
}
102
}
103
104