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
tschatzl@7072 | 1 | /* |
tschatzl@7072 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
tschatzl@7072 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
tschatzl@7072 | 4 | * |
tschatzl@7072 | 5 | * This code is free software; you can redistribute it and/or modify it |
tschatzl@7072 | 6 | * under the terms of the GNU General Public License version 2 only, as |
tschatzl@7072 | 7 | * published by the Free Software Foundation. |
tschatzl@7072 | 8 | * |
tschatzl@7072 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
tschatzl@7072 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
tschatzl@7072 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
tschatzl@7072 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
tschatzl@7072 | 13 | * accompanied this code). |
tschatzl@7072 | 14 | * |
tschatzl@7072 | 15 | * You should have received a copy of the GNU General Public License version |
tschatzl@7072 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
tschatzl@7072 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
tschatzl@7072 | 18 | * |
tschatzl@7072 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
tschatzl@7072 | 20 | * or visit www.oracle.com if you need additional information or have any |
tschatzl@7072 | 21 | * questions. |
tschatzl@7072 | 22 | */ |
tschatzl@7072 | 23 | |
tschatzl@7072 | 24 | /* |
tschatzl@7072 | 25 | * @test TestWBGC |
tschatzl@7072 | 26 | * @bug 8055098 |
tschatzl@7072 | 27 | * @summary Test verify that WB methods isObjectInOldGen and youngGC works correctly. |
tschatzl@7072 | 28 | * @library /testlibrary /testlibrary/whitebox |
tschatzl@7072 | 29 | * @build TestWBGC |
tschatzl@7072 | 30 | * @run main ClassFileInstaller sun.hotspot.WhiteBox |
tschatzl@7072 | 31 | * @run driver TestWBGC |
tschatzl@7072 | 32 | */ |
tschatzl@7072 | 33 | import com.oracle.java.testlibrary.*; |
tschatzl@7072 | 34 | import sun.hotspot.WhiteBox; |
tschatzl@7072 | 35 | |
tschatzl@7072 | 36 | public class TestWBGC { |
tschatzl@7072 | 37 | |
tschatzl@7072 | 38 | public static void main(String args[]) throws Exception { |
tschatzl@7072 | 39 | ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
tschatzl@7072 | 40 | true, |
tschatzl@7072 | 41 | "-Xbootclasspath/a:.", |
tschatzl@7072 | 42 | "-XX:+UnlockDiagnosticVMOptions", |
tschatzl@7072 | 43 | "-XX:+WhiteBoxAPI", |
tschatzl@7072 | 44 | "-XX:MaxTenuringThreshold=1", |
tschatzl@7072 | 45 | "-XX:+PrintGC", |
tschatzl@7072 | 46 | GCYoungTest.class.getName()); |
tschatzl@7072 | 47 | |
tschatzl@7072 | 48 | OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
tschatzl@7072 | 49 | System.out.println(output.getStdout()); |
tschatzl@7072 | 50 | output.shouldHaveExitValue(0); |
tschatzl@7072 | 51 | output.shouldContain("WhiteBox Initiated Young GC"); |
tschatzl@7072 | 52 | output.shouldNotContain("Full"); |
tschatzl@7072 | 53 | // To be sure that we don't provoke Full GC additionaly to young |
tschatzl@7072 | 54 | } |
tschatzl@7072 | 55 | |
tschatzl@7072 | 56 | public static class GCYoungTest { |
tschatzl@7072 | 57 | static WhiteBox wb = WhiteBox.getWhiteBox(); |
tschatzl@7072 | 58 | public static Object obj; |
tschatzl@7072 | 59 | |
tschatzl@7072 | 60 | public static void main(String args[]) { |
tschatzl@7072 | 61 | obj = new Object(); |
tschatzl@7072 | 62 | Asserts.assertFalse(wb.isObjectInOldGen(obj)); |
tschatzl@7072 | 63 | wb.youngGC(); |
tschatzl@7072 | 64 | wb.youngGC(); |
tschatzl@7072 | 65 | // 2 young GC is needed to promote object into OldGen |
tschatzl@7072 | 66 | Asserts.assertTrue(wb.isObjectInOldGen(obj)); |
tschatzl@7072 | 67 | } |
tschatzl@7072 | 68 | } |
tschatzl@7072 | 69 | } |