Path: blob/master/test/hotspot/jtreg/gc/shenandoah/TestObjItrWithHeapDump.java
40942 views
/*1* Copyright (c) 2019, 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 TestObjIterWithHeapDump26* @summary Test heap dump triggered heap object iteration27* @bug 822501428* @requires vm.gc.Shenandoah29* @library /test/lib30* @run driver TestObjItrWithHeapDump31*/3233import java.util.*;3435import jdk.test.lib.process.ProcessTools;36import jdk.test.lib.process.OutputAnalyzer;3738public class TestObjItrWithHeapDump {39public static void testWith(String... args) throws Exception {40String[] cmds = Arrays.copyOf(args, args.length + 2);41cmds[args.length] = TestObjItrWithHeapDump.class.getName();42cmds[args.length + 1] = "test";43ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds);4445OutputAnalyzer output = new OutputAnalyzer(pb.start());46output.shouldHaveExitValue(0);47output.shouldContain("Class Histogram (before full gc)");48output.shouldContain("Class Histogram (after full gc)");49}5051public static void main(String[] args) throws Exception {52if (args.length > 0 && args[0].equals("test")) {53System.gc();54System.exit(0);55}5657String[][][] modeHeuristics = new String[][][] {58{{"satb"}, {"adaptive", "compact", "static", "aggressive"}},59{{"iu"}, {"adaptive", "aggressive"}},60{{"passive"}, {"passive"}}61};6263for (String[][] mh : modeHeuristics) {64String mode = mh[0][0];65String[] heuristics = mh[1];66for (String h : heuristics) {67testWith("-XX:+UnlockDiagnosticVMOptions",68"-XX:+UnlockExperimentalVMOptions",69"-XX:+UseShenandoahGC",70"-XX:-ShenandoahDegeneratedGC",71"-XX:ShenandoahGCMode=" + mode,72"-XX:ShenandoahGCHeuristics=" + h,73"-Xlog:gc+classhisto=trace",74"-XX:-ExplicitGCInvokesConcurrent",75"-Xmx512M"76);77}78}79}80}818283