Path: blob/master/test/hotspot/jtreg/gc/shenandoah/TestDynamicSoftMaxHeapSize.java
40942 views
/*1* Copyright (c) 2020, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324/*25* @test TestDynamicSoftMaxHeapSize26* @requires vm.gc.Shenandoah27* @library /test/lib28*29* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions30* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive31* -XX:+ShenandoahDegeneratedGC32* -Dtarget=1000033* TestDynamicSoftMaxHeapSize34*35* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions36* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive37* -XX:-ShenandoahDegeneratedGC38* -Dtarget=1000039* TestDynamicSoftMaxHeapSize40*/4142/*43* @test TestDynamicSoftMaxHeapSize44* @requires vm.gc.Shenandoah45* @library /test/lib46*47* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions48* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive49* -Dtarget=100050* TestDynamicSoftMaxHeapSize51*/5253/*54* @test TestDynamicSoftMaxHeapSize55* @requires vm.gc.Shenandoah56* @library /test/lib57*58* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions59* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive60* -Dtarget=1000061* TestDynamicSoftMaxHeapSize62*/6364/*65* @test TestDynamicSoftMaxHeapSize66* @requires vm.gc.Shenandoah67* @library /test/lib68*69* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions70* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static71* -Dtarget=1000072* TestDynamicSoftMaxHeapSize73*/7475/*76* @test TestDynamicSoftMaxHeapSize77* @requires vm.gc.Shenandoah78* @library /test/lib79*80* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions81* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact82* -Dtarget=100083* TestDynamicSoftMaxHeapSize84*/8586/*87* @test TestDynamicSoftMaxHeapSize88* @requires vm.gc.Shenandoah89* @library /test/lib90*91* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions92* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive93* -Dtarget=100094* TestDynamicSoftMaxHeapSize95*/9697/*98* @test TestDynamicSoftMaxHeapSize99* @requires vm.gc.Shenandoah100* @library /test/lib101*102* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions103* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu104* -Dtarget=10000105* TestDynamicSoftMaxHeapSize106*/107108import java.util.Random;109import jdk.test.lib.Utils;110import jdk.test.lib.process.OutputAnalyzer;111import jdk.test.lib.process.ProcessTools;112import jdk.test.lib.dcmd.PidJcmdExecutor;113114public class TestDynamicSoftMaxHeapSize {115116static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation117static final long STRIDE = 10_000_000;118119static volatile Object sink;120121public static void main(String[] args) throws Exception {122long count = TARGET_MB * 1024 * 1024 / 16;123Random r = Utils.getRandomInstance();124PidJcmdExecutor jcmd = new PidJcmdExecutor();125126for (long c = 0; c < count; c += STRIDE) {127// Sizes specifically include heaps below Xms and above Xmx to test saturation code.128jcmd.execute("VM.set_flag SoftMaxHeapSize " + r.nextInt(768*1024*1024), true);129for (long s = 0; s < STRIDE; s++) {130sink = new Object();131}132Thread.sleep(1);133}134}135136}137138139