Mercurial > hg > graal-compiler
comparison test/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java @ 20282:f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
Summary: Added -XX:+/-ClassUnloadingWithConcurrentMark
Reviewed-by: jmasa, brutisso, mgerdin
author | stefank |
---|---|
date | Wed, 06 Aug 2014 09:55:16 +0200 |
parents | |
children | 8a7429682242 |
comparison
equal
deleted
inserted
replaced
20281:684a5dec6072 | 20282:f3aeae1f9fc5 |
---|---|
1 /* | |
2 * Copyright (c) 2014, 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 /* | |
25 * @test | |
26 * @key gc | |
27 * @bug 8049831 | |
28 * @library /testlibrary /testlibrary/whitebox | |
29 * @build TestCMSClassUnloadingEnabledHWM AllocateBeyondMetaspaceSize | |
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox | |
31 * @run driver TestCMSClassUnloadingEnabledHWM | |
32 * @summary Test that -XX:-CMSClassUnloadingEnabled will trigger a Full GC when more than MetaspaceSize metadata is allocated. | |
33 */ | |
34 | |
35 import com.oracle.java.testlibrary.OutputAnalyzer; | |
36 import com.oracle.java.testlibrary.ProcessTools; | |
37 | |
38 import java.util.ArrayList; | |
39 import java.util.Arrays; | |
40 | |
41 public class TestCMSClassUnloadingEnabledHWM { | |
42 private static long MetaspaceSize = 32 * 1024 * 1024; | |
43 private static long YoungGenSize = 32 * 1024 * 1024; | |
44 | |
45 private static OutputAnalyzer run(boolean enableUnloading) throws Exception { | |
46 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( | |
47 "-Xbootclasspath/a:.", | |
48 "-XX:+WhiteBoxAPI", | |
49 "-XX:MetaspaceSize=" + MetaspaceSize, | |
50 "-Xmn" + YoungGenSize, | |
51 "-XX:+UseConcMarkSweepGC", | |
52 "-XX:" + (enableUnloading ? "+" : "-") + "CMSClassUnloadingEnabled", | |
53 "-XX:+PrintHeapAtGC", | |
54 "-XX:+PrintGCDetails", | |
55 "AllocateBeyondMetaspaceSize", | |
56 "" + MetaspaceSize, | |
57 "" + YoungGenSize); | |
58 return new OutputAnalyzer(pb.start()); | |
59 } | |
60 | |
61 public static OutputAnalyzer runWithCMSClassUnloading() throws Exception { | |
62 return run(true); | |
63 } | |
64 | |
65 public static OutputAnalyzer runWithoutCMSClassUnloading() throws Exception { | |
66 return run(false); | |
67 } | |
68 | |
69 public static void testWithoutCMSClassUnloading() throws Exception { | |
70 // -XX:-CMSClassUnloadingEnabled is used, so we expect a full GC instead of a concurrent cycle. | |
71 OutputAnalyzer out = runWithoutCMSClassUnloading(); | |
72 | |
73 out.shouldMatch(".*Full GC.*"); | |
74 out.shouldNotMatch(".*CMS Initial Mark.*"); | |
75 } | |
76 | |
77 public static void testWithCMSClassUnloading() throws Exception { | |
78 // -XX:+CMSClassUnloadingEnabled is used, so we expect a concurrent cycle instead of a full GC. | |
79 OutputAnalyzer out = runWithCMSClassUnloading(); | |
80 | |
81 out.shouldMatch(".*CMS Initial Mark.*"); | |
82 out.shouldNotMatch(".*Full GC.*"); | |
83 } | |
84 | |
85 public static void main(String args[]) throws Exception { | |
86 testWithCMSClassUnloading(); | |
87 testWithoutCMSClassUnloading(); | |
88 } | |
89 } | |
90 |