8179084: HotSpot VM fails to start when AggressiveHeap is set

Fri, 28 Apr 2017 21:14:37 -0400

author
dholmes
date
Fri, 28 Apr 2017 21:14:37 -0400
changeset 8763
afff7bd98f7d
parent 8762
654eaca01d61
child 8764
0bd600d6d77b

8179084: HotSpot VM fails to start when AggressiveHeap is set
Reviewed-by: kbarrett, stefank

src/share/vm/runtime/arguments.cpp file | annotate | diff | comparison | revisions
test/TEST.groups file | annotate | diff | comparison | revisions
test/gc/arguments/TestAggressiveHeap.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/runtime/arguments.cpp	Wed Apr 26 10:40:06 2017 -0400
     1.2 +++ b/src/share/vm/runtime/arguments.cpp	Fri Apr 28 21:14:37 2017 -0400
     1.3 @@ -3193,8 +3193,6 @@
     1.4  
     1.5        // Enable parallel GC and adaptive generation sizing
     1.6        FLAG_SET_CMDLINE(bool, UseParallelGC, true);
     1.7 -      FLAG_SET_DEFAULT(ParallelGCThreads,
     1.8 -                       Abstract_VM_Version::parallel_worker_threads());
     1.9  
    1.10        // Encourage steady state memory management
    1.11        FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100);
     2.1 --- a/test/TEST.groups	Wed Apr 26 10:40:06 2017 -0400
     2.2 +++ b/test/TEST.groups	Fri Apr 28 21:14:37 2017 -0400
     2.3 @@ -1,5 +1,5 @@
     2.4  #
     2.5 -# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
     2.6 +# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
     2.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8  #
     2.9  # This code is free software; you can redistribute it and/or modify it
    2.10 @@ -164,6 +164,7 @@
    2.11    gc/TestGCLogRotationViaJcmd.java \
    2.12    gc/g1/TestHumongousAllocInitialMark.java \
    2.13    gc/g1/TestHumongousShrinkHeap.java \
    2.14 +  gc/arguments/TestAggressiveHeap.java \
    2.15    gc/arguments/TestG1HeapRegionSize.java \
    2.16    gc/metaspace/TestMetaspaceMemoryPool.java \
    2.17    gc/arguments/TestDynMinHeapFreeRatio.java \
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/gc/arguments/TestAggressiveHeap.java	Fri Apr 28 21:14:37 2017 -0400
     3.3 @@ -0,0 +1,91 @@
     3.4 +/*
     3.5 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +
    3.27 +/*
    3.28 + * @test TestAggressiveHeap
    3.29 + * @key gc
    3.30 + * @bug 8179084
    3.31 + * @summary Test argument processing for -XX:+AggressiveHeap.
    3.32 + * @library /testlibrary
    3.33 + * @run driver TestAggressiveHeap
    3.34 + */
    3.35 +
    3.36 +import java.lang.management.ManagementFactory;
    3.37 +import javax.management.MBeanServer;
    3.38 +import javax.management.ObjectName;
    3.39 +
    3.40 +import com.oracle.java.testlibrary.OutputAnalyzer;
    3.41 +import com.oracle.java.testlibrary.ProcessTools;
    3.42 +
    3.43 +public class TestAggressiveHeap {
    3.44 +
    3.45 +    public static void main(String args[]) throws Exception {
    3.46 +        if (canUseAggressiveHeapOption()) {
    3.47 +            testFlag();
    3.48 +        }
    3.49 +    }
    3.50 +
    3.51 +    // Note: Not a normal boolean flag; -XX:-AggressiveHeap is invalid.
    3.52 +    private static final String option = "-XX:+AggressiveHeap";
    3.53 +
    3.54 +    // Option requires at least 256M, else error during option processing.
    3.55 +    private static final long minMemory = 256 * 1024 * 1024;
    3.56 +
    3.57 +    // bool UseParallelGC := true {product}
    3.58 +    private static final String parallelGCPattern =
    3.59 +        " *bool +UseParallelGC *:= *true +\\{product\\}";
    3.60 +
    3.61 +    private static void testFlag() throws Exception {
    3.62 +        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    3.63 +            option, "-XX:+PrintFlagsFinal", "-version");
    3.64 +
    3.65 +        OutputAnalyzer output = new OutputAnalyzer(pb.start());
    3.66 +
    3.67 +        output.shouldHaveExitValue(0);
    3.68 +
    3.69 +        String value = output.firstMatch(parallelGCPattern);
    3.70 +        if (value == null) {
    3.71 +            throw new RuntimeException(
    3.72 +                option + " didn't set UseParallelGC");
    3.73 +        }
    3.74 +    }
    3.75 +
    3.76 +    private static boolean haveRequiredMemory() throws Exception {
    3.77 +        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    3.78 +        ObjectName os = new ObjectName("java.lang", "type", "OperatingSystem");
    3.79 +        Object attr = server.getAttribute(os, "TotalPhysicalMemorySize");
    3.80 +        String value = attr.toString();
    3.81 +        long memory = Long.parseLong(value);
    3.82 +        return memory >= minMemory;
    3.83 +    }
    3.84 +
    3.85 +    private static boolean canUseAggressiveHeapOption() throws Exception {
    3.86 +        if (!haveRequiredMemory()) {
    3.87 +            System.out.println(
    3.88 +                "Skipping test of " + option + " : insufficient memory");
    3.89 +            return false;
    3.90 +        }
    3.91 +        return true;
    3.92 +    }
    3.93 +}
    3.94 +

mercurial