author | iignatyev |
Wed, 02 Aug 2017 08:53:18 -0700 (2017-08-02) | |
changeset 46743 | 4d9e00487c62 |
parent 45113 | 1527aaaeb42d |
permissions | -rw-r--r-- |
24095
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
1 |
/* |
38083
2ffb46735fec
8154843: GC tests should be correctly marked with @module
mchernov
parents:
30764
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, 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 |
|
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
24 |
/** |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
25 |
* @test TestDynShrinkHeap |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
26 |
* @bug 8016479 |
39414
4adf52148100
8160088: update hotspot tests depending on GC to use @requires vm.gc.X
dfazunen
parents:
38152
diff
changeset
|
27 |
* @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
|
28 |
* @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
|
29 |
* @modules java.base/jdk.internal.misc |
38083
2ffb46735fec
8154843: GC tests should be correctly marked with @module
mchernov
parents:
30764
diff
changeset
|
30 |
* @modules jdk.management |
43403
9a09e7b9f0e1
8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents:
40631
diff
changeset
|
31 |
* @library /test/lib / |
24667
38c5d155aee9
8040250: The test test/gc/parallelScavenge/TestDynShrinkHeap.java fails with OOME
iignatyev
parents:
24473
diff
changeset
|
32 |
* @run main/othervm -XX:+UseAdaptiveSizePolicyWithSystemGC -XX:+UseParallelGC -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 -Xmx1g -verbose:gc TestDynShrinkHeap |
24095
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
33 |
*/ |
45113
1527aaaeb42d
8180004: jdk.test.lib.DynamicVMOption should be moved to jdk.test.lib.management
iignatyev
parents:
43403
diff
changeset
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
import java.util.ArrayList; |
43403
9a09e7b9f0e1
8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents:
40631
diff
changeset
|
38 |
import java.text.NumberFormat; |
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
30247
diff
changeset
|
39 |
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
|
40 |
import com.sun.management.HotSpotDiagnosticMXBean; |
43403
9a09e7b9f0e1
8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents:
40631
diff
changeset
|
41 |
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
|
42 |
|
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
43 |
public class TestDynShrinkHeap { |
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 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
|
46 |
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
|
47 |
|
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
48 |
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
|
49 |
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
|
50 |
|
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
51 |
public TestDynShrinkHeap() { |
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 |
|
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
54 |
private final void test() { |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
55 |
System.gc(); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
56 |
MemoryUsagePrinter.printMemoryUsage("init"); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
57 |
|
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
58 |
eat(); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
59 |
MemoryUsagePrinter.printMemoryUsage("eaten"); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
60 |
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
|
61 |
|
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
62 |
free(); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
63 |
MemoryUsagePrinter.printMemoryUsage("free"); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
64 |
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
|
65 |
|
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
66 |
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
|
67 |
"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
|
68 |
+ "%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
|
69 |
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
|
70 |
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
|
71 |
.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
|
72 |
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
|
73 |
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
|
74 |
.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
|
75 |
)); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
76 |
} |
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 |
private void eat() { |
24667
38c5d155aee9
8040250: The test test/gc/parallelScavenge/TestDynShrinkHeap.java fails with OOME
iignatyev
parents:
24473
diff
changeset
|
79 |
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
|
80 |
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
|
81 |
} |
24667
38c5d155aee9
8040250: The test test/gc/parallelScavenge/TestDynShrinkHeap.java fails with OOME
iignatyev
parents:
24473
diff
changeset
|
82 |
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
|
83 |
|
24667
38c5d155aee9
8040250: The test test/gc/parallelScavenge/TestDynShrinkHeap.java fails with OOME
iignatyev
parents:
24473
diff
changeset
|
84 |
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
|
85 |
System.gc(); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
86 |
MemoryUsagePrinter.printMemoryUsage("array halved"); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
87 |
} |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
88 |
|
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
89 |
private void free() { |
24473
1227042cdc67
8039489: Refactor test framework for dynamic VM options
iignatyev
parents:
24095
diff
changeset
|
90 |
int min = DynamicVMOption.getInt(MIN_FREE_RATIO_FLAG_NAME); |
1227042cdc67
8039489: Refactor test framework for dynamic VM options
iignatyev
parents:
24095
diff
changeset
|
91 |
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
|
92 |
System.gc(); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
93 |
MemoryUsagePrinter.printMemoryUsage("under pressure"); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
94 |
} |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
95 |
|
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
96 |
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
|
97 |
new TestDynShrinkHeap().test(); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
98 |
} |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
99 |
} |
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 |
* 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
|
103 |
*/ |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
104 |
class MemoryUsagePrinter { |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
105 |
|
43403
9a09e7b9f0e1
8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents:
40631
diff
changeset
|
106 |
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
|
107 |
|
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
108 |
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
|
109 |
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
|
110 |
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
|
111 |
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
|
112 |
label, |
43403
9a09e7b9f0e1
8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents:
40631
diff
changeset
|
113 |
NF.format(memusage.getInit()), |
9a09e7b9f0e1
8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents:
40631
diff
changeset
|
114 |
NF.format(memusage.getUsed()), |
9a09e7b9f0e1
8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot
dfazunen
parents:
40631
diff
changeset
|
115 |
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
|
116 |
freeratio * 100 |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
117 |
); |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
118 |
} |
5a5cf6765809
8037924: CMM Testing: Check Min/MaxHeapFreeRatio flags allows to shrink the heap when using ParallelGC
jwilhelm
parents:
diff
changeset
|
119 |
} |