Wed, 27 Aug 2014 08:19:12 -0400
8046598: Scalable Native memory tracking development
Summary: Enhance scalability of native memory tracking
Reviewed-by: coleenp, ctornqvi, gtriantafill
stefank@6996 | 1 | /* |
stefank@6996 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
stefank@6996 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
stefank@6996 | 4 | * |
stefank@6996 | 5 | * This code is free software; you can redistribute it and/or modify it |
stefank@6996 | 6 | * under the terms of the GNU General Public License version 2 only, as |
stefank@6996 | 7 | * published by the Free Software Foundation. |
stefank@6996 | 8 | * |
stefank@6996 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
stefank@6996 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
stefank@6996 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
stefank@6996 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
stefank@6996 | 13 | * accompanied this code). |
stefank@6996 | 14 | * |
stefank@6996 | 15 | * You should have received a copy of the GNU General Public License version |
stefank@6996 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
stefank@6996 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
stefank@6996 | 18 | * |
stefank@6996 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
stefank@6996 | 20 | * or visit www.oracle.com if you need additional information or have any |
stefank@6996 | 21 | * questions. |
stefank@6996 | 22 | */ |
stefank@6996 | 23 | |
stefank@6996 | 24 | /* |
stefank@6996 | 25 | * @test |
stefank@6996 | 26 | * @key gc |
stefank@6996 | 27 | * @bug 8049831 |
stefank@6996 | 28 | * @library /testlibrary /testlibrary/whitebox |
stefank@6996 | 29 | * @build TestG1ClassUnloadingHWM AllocateBeyondMetaspaceSize |
stefank@6996 | 30 | * @run main ClassFileInstaller sun.hotspot.WhiteBox |
stefank@6996 | 31 | * @run driver TestG1ClassUnloadingHWM |
stefank@6996 | 32 | * @summary Test that -XX:-ClassUnloadingWithConcurrentMark will trigger a Full GC when more than MetaspaceSize metadata is allocated. |
stefank@6996 | 33 | */ |
stefank@6996 | 34 | |
stefank@6996 | 35 | import com.oracle.java.testlibrary.OutputAnalyzer; |
stefank@6996 | 36 | import com.oracle.java.testlibrary.ProcessTools; |
stefank@6996 | 37 | |
stefank@6996 | 38 | import java.util.ArrayList; |
stefank@6996 | 39 | import java.util.Arrays; |
stefank@6996 | 40 | |
stefank@6996 | 41 | public class TestG1ClassUnloadingHWM { |
stefank@6996 | 42 | private static long MetaspaceSize = 32 * 1024 * 1024; |
stefank@6996 | 43 | private static long YoungGenSize = 32 * 1024 * 1024; |
stefank@6996 | 44 | |
stefank@6996 | 45 | private static OutputAnalyzer run(boolean enableUnloading) throws Exception { |
stefank@6996 | 46 | ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
stefank@6996 | 47 | "-Xbootclasspath/a:.", |
stefank@7044 | 48 | "-XX:+UnlockDiagnosticVMOptions", |
stefank@6996 | 49 | "-XX:+WhiteBoxAPI", |
stefank@6996 | 50 | "-XX:MetaspaceSize=" + MetaspaceSize, |
stefank@6996 | 51 | "-Xmn" + YoungGenSize, |
stefank@6996 | 52 | "-XX:+UseG1GC", |
stefank@6996 | 53 | "-XX:" + (enableUnloading ? "+" : "-") + "ClassUnloadingWithConcurrentMark", |
stefank@6996 | 54 | "-XX:+PrintHeapAtGC", |
stefank@6996 | 55 | "-XX:+PrintGCDetails", |
stefank@6996 | 56 | "AllocateBeyondMetaspaceSize", |
stefank@6996 | 57 | "" + MetaspaceSize, |
stefank@6996 | 58 | "" + YoungGenSize); |
stefank@6996 | 59 | return new OutputAnalyzer(pb.start()); |
stefank@6996 | 60 | } |
stefank@6996 | 61 | |
stefank@6996 | 62 | public static OutputAnalyzer runWithG1ClassUnloading() throws Exception { |
stefank@6996 | 63 | return run(true); |
stefank@6996 | 64 | } |
stefank@6996 | 65 | |
stefank@6996 | 66 | public static OutputAnalyzer runWithoutG1ClassUnloading() throws Exception { |
stefank@6996 | 67 | return run(false); |
stefank@6996 | 68 | } |
stefank@6996 | 69 | |
stefank@6996 | 70 | public static void testWithoutG1ClassUnloading() throws Exception { |
stefank@6996 | 71 | // -XX:-ClassUnloadingWithConcurrentMark is used, so we expect a full GC instead of a concurrent cycle. |
stefank@6996 | 72 | OutputAnalyzer out = runWithoutG1ClassUnloading(); |
stefank@6996 | 73 | |
stefank@6996 | 74 | out.shouldMatch(".*Full GC.*"); |
stefank@6996 | 75 | out.shouldNotMatch(".*initial-mark.*"); |
stefank@6996 | 76 | } |
stefank@6996 | 77 | |
stefank@6996 | 78 | public static void testWithG1ClassUnloading() throws Exception { |
stefank@6996 | 79 | // -XX:+ClassUnloadingWithConcurrentMark is used, so we expect a concurrent cycle instead of a full GC. |
stefank@6996 | 80 | OutputAnalyzer out = runWithG1ClassUnloading(); |
stefank@6996 | 81 | |
stefank@6996 | 82 | out.shouldMatch(".*initial-mark.*"); |
stefank@6996 | 83 | out.shouldNotMatch(".*Full GC.*"); |
stefank@6996 | 84 | } |
stefank@6996 | 85 | |
stefank@6996 | 86 | public static void main(String args[]) throws Exception { |
stefank@6996 | 87 | testWithG1ClassUnloading(); |
stefank@6996 | 88 | testWithoutG1ClassUnloading(); |
stefank@6996 | 89 | } |
stefank@6996 | 90 | } |
stefank@6996 | 91 |