Path: blob/master/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocation.java
41155 views
/*1* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2020 SAP SE. 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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425/*26* @test id=debug27* @bug 825115828* @library /test/lib29* @modules java.base/jdk.internal.misc30* java.management31* @build sun.hotspot.WhiteBox32* @requires (vm.debug == true)33*34* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox35*36* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:VerifyMetaspaceInterval=10 TestMetaspaceAllocation37* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:VerifyMetaspaceInterval=10 -XX:MetaspaceReclaimPolicy=none TestMetaspaceAllocation38* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:VerifyMetaspaceInterval=10 -XX:MetaspaceReclaimPolicy=aggressive TestMetaspaceAllocation39* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:VerifyMetaspaceInterval=10 -XX:+MetaspaceGuardAllocations TestMetaspaceAllocation40*41*/4243/*44* @test id=ndebug45* @bug 825115846* @library /test/lib47* @modules java.base/jdk.internal.misc48* java.management49* @build sun.hotspot.WhiteBox50* @requires (vm.debug == false)51*52* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox53*54* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestMetaspaceAllocation55* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:MetaspaceReclaimPolicy=none TestMetaspaceAllocation56* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:MetaspaceReclaimPolicy=aggressive TestMetaspaceAllocation57*/5859public class TestMetaspaceAllocation {6061public static void main(String[] args) {6263MetaspaceTestContext context = new MetaspaceTestContext();64MetaspaceTestArena arena1 = context.createArena(false, 1024 * 1024 * 4);65MetaspaceTestArena arena2 = context.createArena(true,1024 * 1024 * 4);6667Allocation a1 = arena1.allocate(100);68Allocation a2 = arena2.allocate(100);6970long used = context.usedWords();71long committed = context.committedWords();7273System.out.println("used " + used + " committed " + committed);7475arena1.deallocate(a1);7677context.destroyArena(arena2);78context.destroyArena(arena1);7980context.purge();8182context.destroy();8384}85}868788