test/gc/metaspace/TestMetaspaceMemoryPool.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 5716
73d0d0218068
child 6876
710a3c8b516e
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

ehelin@5312 1 /*
ehelin@5312 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
ehelin@5312 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ehelin@5312 4 *
ehelin@5312 5 * This code is free software; you can redistribute it and/or modify it
ehelin@5312 6 * under the terms of the GNU General Public License version 2 only, as
ehelin@5312 7 * published by the Free Software Foundation.
ehelin@5312 8 *
ehelin@5312 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ehelin@5312 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ehelin@5312 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ehelin@5312 12 * version 2 for more details (a copy is included in the LICENSE file that
ehelin@5312 13 * accompanied this code).
ehelin@5312 14 *
ehelin@5312 15 * You should have received a copy of the GNU General Public License version
ehelin@5312 16 * 2 along with this work; if not, write to the Free Software Foundation,
ehelin@5312 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ehelin@5312 18 *
ehelin@5312 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ehelin@5312 20 * or visit www.oracle.com if you need additional information or have any
ehelin@5312 21 * questions.
ehelin@5312 22 */
ehelin@5312 23
ehelin@5312 24 import java.util.List;
ehelin@5716 25 import java.lang.management.*;
ehelin@5716 26 import com.oracle.java.testlibrary.*;
ehelin@5716 27 import static com.oracle.java.testlibrary.Asserts.*;
ehelin@5312 28
ehelin@5312 29 /* @test TestMetaspaceMemoryPool
ehelin@5312 30 * @bug 8000754
ehelin@5312 31 * @summary Tests that a MemoryPoolMXBeans is created for metaspace and that a
ehelin@5312 32 * MemoryManagerMXBean is created.
ehelin@5716 33 * @library /testlibrary
ehelin@5312 34 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops TestMetaspaceMemoryPool
ehelin@5312 35 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:MaxMetaspaceSize=60m TestMetaspaceMemoryPool
ehelin@5694 36 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers TestMetaspaceMemoryPool
ehelin@5694 37 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:CompressedClassSpaceSize=60m TestMetaspaceMemoryPool
ehelin@5312 38 */
ehelin@5312 39 public class TestMetaspaceMemoryPool {
ehelin@5312 40 public static void main(String[] args) {
ehelin@5312 41 verifyThatMetaspaceMemoryManagerExists();
ehelin@5312 42
ehelin@5716 43 boolean isMetaspaceMaxDefined = InputArguments.containsPrefix("-XX:MaxMetaspaceSize");
ehelin@5716 44 verifyMemoryPool(getMemoryPool("Metaspace"), isMetaspaceMaxDefined);
ehelin@5716 45
ehelin@5716 46 if (Platform.is64bit()) {
ehelin@5716 47 if (InputArguments.contains("-XX:+UseCompressedOops")) {
ehelin@5312 48 MemoryPoolMXBean cksPool = getMemoryPool("Compressed Class Space");
ehelin@5312 49 verifyMemoryPool(cksPool, true);
ehelin@5312 50 }
ehelin@5312 51 }
ehelin@5312 52 }
ehelin@5312 53
ehelin@5312 54 private static void verifyThatMetaspaceMemoryManagerExists() {
ehelin@5312 55 List<MemoryManagerMXBean> managers = ManagementFactory.getMemoryManagerMXBeans();
ehelin@5312 56 for (MemoryManagerMXBean manager : managers) {
ehelin@5312 57 if (manager.getName().equals("Metaspace Manager")) {
ehelin@5312 58 return;
ehelin@5312 59 }
ehelin@5312 60 }
ehelin@5312 61
ehelin@5312 62 throw new RuntimeException("Expected to find a metaspace memory manager");
ehelin@5312 63 }
ehelin@5312 64
ehelin@5312 65 private static MemoryPoolMXBean getMemoryPool(String name) {
ehelin@5312 66 List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
ehelin@5312 67 for (MemoryPoolMXBean pool : pools) {
ehelin@5312 68 if (pool.getName().equals(name)) {
ehelin@5312 69 return pool;
ehelin@5312 70 }
ehelin@5312 71 }
ehelin@5312 72
ehelin@5312 73 throw new RuntimeException("Expected to find a memory pool with name " + name);
ehelin@5312 74 }
ehelin@5312 75
ehelin@5312 76 private static void verifyMemoryPool(MemoryPoolMXBean pool, boolean isMaxDefined) {
ehelin@5312 77 MemoryUsage mu = pool.getUsage();
ehelin@5716 78 long init = mu.getInit();
ehelin@5716 79 long used = mu.getUsed();
ehelin@5716 80 long committed = mu.getCommitted();
ehelin@5716 81 long max = mu.getMax();
ehelin@5716 82
ehelin@5716 83 assertGTE(init, 0L);
ehelin@5716 84 assertGTE(used, init);
ehelin@5716 85 assertGTE(committed, used);
ehelin@5312 86
ehelin@5312 87 if (isMaxDefined) {
ehelin@5716 88 assertGTE(max, committed);
ehelin@5312 89 } else {
ehelin@5716 90 assertEQ(max, -1L);
ehelin@5312 91 }
ehelin@5312 92 }
ehelin@5312 93 }

mercurial