Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/TestDynamicSoftMaxHeapSize.java
32284 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* @library /testlibrary27*28* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions29* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive30* -XX:+ShenandoahDegeneratedGC31* -Dtarget=1000032* TestDynamicSoftMaxHeapSize33*34* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions35* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive36* -XX:-ShenandoahDegeneratedGC37* -Dtarget=1000038* TestDynamicSoftMaxHeapSize39*/4041/*42* @test TestDynamicSoftMaxHeapSize43* @library /testlibrary44*45* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions46* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive47* -Dtarget=100048* TestDynamicSoftMaxHeapSize49*/5051/*52* @test TestDynamicSoftMaxHeapSize53* @library /testlibrary54*55* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions56* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive57* -Dtarget=1000058* TestDynamicSoftMaxHeapSize59*/6061/*62* @test TestDynamicSoftMaxHeapSize63* @library /testlibrary64*65* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions66* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static67* -Dtarget=1000068* TestDynamicSoftMaxHeapSize69*/7071/*72* @test TestDynamicSoftMaxHeapSize73* @library /testlibrary74*75* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions76* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact77* -Dtarget=100078* TestDynamicSoftMaxHeapSize79*/8081/*82* @test TestDynamicSoftMaxHeapSize83* @library /testlibrary84*85* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions86* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive87* -Dtarget=100088* TestDynamicSoftMaxHeapSize89*/9091/*92* @test TestDynamicSoftMaxHeapSize93* @library /testlibrary94*95* @run main/othervm -Xms16m -Xmx512m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions96* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu97* -Dtarget=1000098* TestDynamicSoftMaxHeapSize99*/100101import java.util.Random;102import com.oracle.java.testlibrary.*;103104public class TestDynamicSoftMaxHeapSize {105106static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation107static final long STRIDE = 10_000_000;108109static volatile Object sink;110111public static void main(String[] args) throws Exception {112long count = TARGET_MB * 1024 * 1024 / 16;113Random r = new Random();114115String pid = Integer.toString(ProcessTools.getProcessId());116ProcessBuilder pb = new ProcessBuilder();117118for (long c = 0; c < count; c += STRIDE) {119// Sizes specifically include heaps below Xms and above Xmx to test saturation code.120pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.set_flag", "ShenandoahSoftMaxHeapSize", "" + r.nextInt(768*1024*1024)});121pb.start().waitFor();122for (long s = 0; s < STRIDE; s++) {123sink = new Object();124}125Thread.sleep(1);126}127}128129}130131132