Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/jdk/jfr/event/gc/detailed/TestG1EvacMemoryStatsEvent.java
42283 views
1
/*
2
* Copyright (c) 2015, 2018, 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
package jdk.jfr.event.gc.detailed;
24
25
import java.util.List;
26
27
import jdk.jfr.Recording;
28
import jdk.jfr.consumer.RecordedEvent;
29
import jdk.test.lib.jfr.EventNames;
30
import jdk.test.lib.jfr.Events;
31
32
/**
33
* @test
34
* @key jfr
35
* @requires vm.hasJFR
36
* @requires vm.gc == "G1" | vm.gc == null
37
* @library /test/lib /test/jdk
38
* @run main/othervm -XX:NewSize=2m -XX:MaxNewSize=2m -Xmx32m -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.event.gc.detailed.TestG1EvacMemoryStatsEvent
39
*/
40
public class TestG1EvacMemoryStatsEvent {
41
42
public static byte[] bytes;
43
44
public static void runTest(String event_name) throws Exception {
45
46
Recording recording = new Recording();
47
48
// activate the event we are interested in and start recording
49
recording.enable(event_name);
50
recording.start();
51
52
// Setting NewSize and MaxNewSize will limit eden, so
53
// allocating 1024 5k byte arrays should trigger at
54
// least one Young GC.
55
for (int i = 0; i < 1024; i++) {
56
bytes = new byte[5 * 1024];
57
}
58
recording.stop();
59
60
// Verify recording
61
List<RecordedEvent> all = Events.fromRecording(recording);
62
for (RecordedEvent e : all) {
63
Events.assertField(e, "statistics.gcId").above(0);
64
}
65
66
recording.close();
67
}
68
69
public static void main(String[] args) throws Exception {
70
runTest(EventNames.G1EvacuationYoungStatistics);
71
runTest(EventNames.G1EvacuationOldStatistics);
72
}
73
74
}
75
76