test/hotspot/jtreg/gc/parallel/TestDynShrinkHeap.java
author epavlova
Thu, 20 Jun 2019 11:42:33 -0700
changeset 55455 76647c08ce0c
parent 53523 4c5184c56dc2
permissions -rw-r--r--
8225684: [AOT] vmTestbase/vm/oom/production/AlwaysOOMProduction tests fail with AOTed java.base Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
     1
/*
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 47216
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
     4
 *
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
     8
 *
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    13
 * accompanied this code).
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    14
 *
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    18
 *
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    21
 * questions.
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    22
 */
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    23
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 47216
diff changeset
    24
package gc.parallel;
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 47216
diff changeset
    25
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    26
/**
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    27
 * @test TestDynShrinkHeap
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    28
 * @bug 8016479
39414
4adf52148100 8160088: update hotspot tests depending on GC to use @requires vm.gc.X
dfazunen
parents: 38152
diff changeset
    29
 * @requires vm.gc.Parallel
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    30
 * @summary Verify that the heap shrinks after full GC according to the current values of the Min/MaxHeapFreeRatio flags
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 38083
diff changeset
    31
 * @modules java.base/jdk.internal.misc
38083
2ffb46735fec 8154843: GC tests should be correctly marked with @module
mchernov
parents: 30764
diff changeset
    32
 * @modules jdk.management
43403
9a09e7b9f0e1 8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents: 40631
diff changeset
    33
 * @library /test/lib /
53523
4c5184c56dc2 8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents: 47216
diff changeset
    34
 * @run main/othervm -XX:+UseAdaptiveSizePolicyWithSystemGC -XX:+UseParallelGC -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 -Xmx1g -verbose:gc gc.parallel.TestDynShrinkHeap
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    35
 */
45113
1527aaaeb42d 8180004: jdk.test.lib.DynamicVMOption should be moved to jdk.test.lib.management
iignatyev
parents: 43403
diff changeset
    36
import jdk.test.lib.management.DynamicVMOption;
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    37
import java.lang.management.ManagementFactory;
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    38
import java.lang.management.MemoryUsage;
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    39
import java.util.ArrayList;
43403
9a09e7b9f0e1 8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents: 40631
diff changeset
    40
import java.text.NumberFormat;
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 30247
diff changeset
    41
import static jdk.test.lib.Asserts.assertLessThan;
30247
9925b07bba5b 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 29466
diff changeset
    42
import com.sun.management.HotSpotDiagnosticMXBean;
43403
9a09e7b9f0e1 8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents: 40631
diff changeset
    43
import gc.testlibrary.Helpers;
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    44
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    45
public class TestDynShrinkHeap {
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    46
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    47
    public static final String MIN_FREE_RATIO_FLAG_NAME = "MinHeapFreeRatio";
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    48
    public static final String MAX_FREE_RATIO_FLAG_NAME = "MaxHeapFreeRatio";
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    49
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    50
    private static ArrayList<byte[]> list = new ArrayList<>(0);
24667
38c5d155aee9 8040250: The test test/gc/parallelScavenge/TestDynShrinkHeap.java fails with OOME
iignatyev
parents: 24473
diff changeset
    51
    private static final int LEN = 512 * 1024 + 1;
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    52
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    53
    public TestDynShrinkHeap() {
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    54
    }
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    55
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    56
    private final void test() {
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    57
        System.gc();
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    58
        MemoryUsagePrinter.printMemoryUsage("init");
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    59
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    60
        eat();
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    61
        MemoryUsagePrinter.printMemoryUsage("eaten");
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    62
        MemoryUsage muFull = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    63
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    64
        free();
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    65
        MemoryUsagePrinter.printMemoryUsage("free");
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    66
        MemoryUsage muFree = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    67
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    68
        assertLessThan(muFree.getCommitted(), muFull.getCommitted(), String.format(
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    69
                "committed free heap size is not less than committed full heap size, heap hasn't been shrunk?%n"
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    70
                + "%s = %s%n%s = %s",
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    71
                MIN_FREE_RATIO_FLAG_NAME,
30247
9925b07bba5b 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 29466
diff changeset
    72
                ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class)
9925b07bba5b 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 29466
diff changeset
    73
                    .getVMOption(MIN_FREE_RATIO_FLAG_NAME).getValue(),
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    74
                MAX_FREE_RATIO_FLAG_NAME,
30247
9925b07bba5b 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 29466
diff changeset
    75
                ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class)
9925b07bba5b 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 29466
diff changeset
    76
                    .getVMOption(MAX_FREE_RATIO_FLAG_NAME).getValue()
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    77
        ));
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    78
    }
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    79
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    80
    private void eat() {
24667
38c5d155aee9 8040250: The test test/gc/parallelScavenge/TestDynShrinkHeap.java fails with OOME
iignatyev
parents: 24473
diff changeset
    81
        for (int i = 0; i < LEN; i++) {
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    82
            list.add(new byte[1024]);
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    83
        }
24667
38c5d155aee9 8040250: The test test/gc/parallelScavenge/TestDynShrinkHeap.java fails with OOME
iignatyev
parents: 24473
diff changeset
    84
        MemoryUsagePrinter.printMemoryUsage("allocated " + LEN + " arrays");
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    85
24667
38c5d155aee9 8040250: The test test/gc/parallelScavenge/TestDynShrinkHeap.java fails with OOME
iignatyev
parents: 24473
diff changeset
    86
        list.subList(0, LEN / 2).clear();
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    87
        System.gc();
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    88
        MemoryUsagePrinter.printMemoryUsage("array halved");
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    89
    }
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    90
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    91
    private void free() {
24473
1227042cdc67 8039489: Refactor test framework for dynamic VM options
iignatyev
parents: 24095
diff changeset
    92
        int min = DynamicVMOption.getInt(MIN_FREE_RATIO_FLAG_NAME);
1227042cdc67 8039489: Refactor test framework for dynamic VM options
iignatyev
parents: 24095
diff changeset
    93
        DynamicVMOption.setInt(MAX_FREE_RATIO_FLAG_NAME, min);
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    94
        System.gc();
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    95
        MemoryUsagePrinter.printMemoryUsage("under pressure");
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    96
    }
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    97
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    98
    public static void main(String[] args) {
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
    99
        new TestDynShrinkHeap().test();
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   100
    }
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   101
}
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   102
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   103
/**
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   104
 * Prints memory usage to standard output
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   105
 */
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   106
class MemoryUsagePrinter {
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   107
43403
9a09e7b9f0e1 8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents: 40631
diff changeset
   108
    public static final NumberFormat NF = Helpers.numberFormatter();
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   109
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   110
    public static void printMemoryUsage(String label) {
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   111
        MemoryUsage memusage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   112
        float freeratio = 1f - (float) memusage.getUsed() / memusage.getCommitted();
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   113
        System.out.format("[%-24s] init: %-7s, used: %-7s, comm: %-7s, freeRatio ~= %.1f%%%n",
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   114
                label,
43403
9a09e7b9f0e1 8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents: 40631
diff changeset
   115
                NF.format(memusage.getInit()),
9a09e7b9f0e1 8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents: 40631
diff changeset
   116
                NF.format(memusage.getUsed()),
9a09e7b9f0e1 8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents: 40631
diff changeset
   117
                NF.format(memusage.getCommitted()),
24095
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   118
                freeratio * 100
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   119
        );
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   120
    }
5a5cf6765809 8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff changeset
   121
}