author | iignatyev |
Fri, 14 Sep 2018 14:02:57 -0700 | |
changeset 51754 | 594919232b8f |
parent 51687 | 1e39953aaed8 |
child 59053 | ba6c248cae19 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 4530538 |
|
27 |
* @summary Basic unit test of memory management testing: |
|
28 |
* 1) setUsageThreshold() and getUsageThreshold() |
|
29 |
* 2) test low memory detection on the old generation. |
|
30 |
* @author Mandy Chung |
|
31 |
* |
|
41759
873c7ad14bea
8158797: Test java/lang/management/MemoryMXBean/LowMemoryTest.java fails when GC is specified explicitly
akulyakh
parents:
35246
diff
changeset
|
32 |
* @requires vm.gc == "null" |
28527 | 33 |
* @requires vm.opt.ExplicitGCInvokesConcurrent != "true" |
34 |
* @requires vm.opt.DisableExplicitGC != "true" |
|
51754 | 35 |
* @library /test/lib |
44423 | 36 |
* |
51754 | 37 |
* @build LowMemoryTest MemoryUtil RunUtil |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
47216
diff
changeset
|
38 |
* @build sun.hotspot.WhiteBox |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
47216
diff
changeset
|
39 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
47216
diff
changeset
|
40 |
* @run main/othervm/timeout=600 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. LowMemoryTest |
2 | 41 |
*/ |
42 |
||
43 |
import java.lang.management.*; |
|
44 |
import java.util.*; |
|
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
45 |
import java.util.concurrent.Phaser; |
2 | 46 |
import javax.management.*; |
47 |
import javax.management.openmbean.CompositeData; |
|
51687
1e39953aaed8
8182404: remove jdk.testlibrary.JDKToolFinder and JDKToolLauncher
iignatyev
parents:
51675
diff
changeset
|
48 |
import jdk.test.lib.JDKToolFinder; |
51675 | 49 |
import jdk.test.lib.process.ProcessTools; |
51754 | 50 |
import jdk.test.lib.Utils; |
2 | 51 |
|
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
47216
diff
changeset
|
52 |
import sun.hotspot.code.Compiler; |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
47216
diff
changeset
|
53 |
|
2 | 54 |
public class LowMemoryTest { |
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
55 |
private static final MemoryMXBean mm = ManagementFactory.getMemoryMXBean(); |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
56 |
private static final List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans(); |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
57 |
private static final Phaser phaser = new Phaser(2); |
2 | 58 |
private static MemoryPoolMXBean mpool = null; |
59 |
private static boolean trace = false; |
|
60 |
private static boolean testFailed = false; |
|
61 |
private static final int NUM_TRIGGERS = 5; |
|
62 |
private static final int NUM_CHUNKS = 2; |
|
25999
1e494b91a5a5
8035939: java/lang/management/MemoryMXBean/MemoryManagement.java timed out on Linux-amd64
stefank
parents:
24366
diff
changeset
|
63 |
private static final int YOUNG_GEN_SIZE = 8 * 1024 * 1024; |
2 | 64 |
private static long chunkSize; |
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
65 |
private static final String classMain = "LowMemoryTest$TestMain"; |
2 | 66 |
|
23933
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
67 |
/** |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
68 |
* Run the test multiple times with different GC versions. |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
69 |
* First with default command line specified by the framework. |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
70 |
* Then with GC versions specified by the test. |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
71 |
*/ |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
72 |
public static void main(String a[]) throws Throwable { |
25999
1e494b91a5a5
8035939: java/lang/management/MemoryMXBean/MemoryManagement.java timed out on Linux-amd64
stefank
parents:
24366
diff
changeset
|
73 |
// Use a low young gen size to ensure that the |
1e494b91a5a5
8035939: java/lang/management/MemoryMXBean/MemoryManagement.java timed out on Linux-amd64
stefank
parents:
24366
diff
changeset
|
74 |
// allocated objects are put in the old gen. |
1e494b91a5a5
8035939: java/lang/management/MemoryMXBean/MemoryManagement.java timed out on Linux-amd64
stefank
parents:
24366
diff
changeset
|
75 |
final String nmFlag = "-Xmn" + YOUNG_GEN_SIZE; |
26459
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
76 |
// Using large pages will change the young gen size, |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
77 |
// make sure we don't use them for this test. |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
78 |
final String lpFlag = "-XX:-UseLargePages"; |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
79 |
// Prevent G1 from selecting a large heap region size, |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
80 |
// since that would change the young gen size. |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
81 |
final String g1Flag = "-XX:G1HeapRegionSize=1m"; |
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
82 |
|
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
83 |
// Runs the test collecting subprocess I/O while it's running. |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
84 |
traceTest(classMain + ", -XX:+UseSerialGC", nmFlag, lpFlag, "-XX:+UseSerialGC"); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
85 |
traceTest(classMain + ", -XX:+UseParallelGC", nmFlag, lpFlag, "-XX:+UseParallelGC"); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
86 |
traceTest(classMain + ", -XX:+UseG1GC", nmFlag, lpFlag, "-XX:+UseG1GC", g1Flag); |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
47216
diff
changeset
|
87 |
if (!Compiler.isGraalEnabled()) { // Graal does not support CMS |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
47216
diff
changeset
|
88 |
traceTest(classMain + ", -XX:+UseConcMarkSweepGC", nmFlag, lpFlag, "-XX:+UseConcMarkSweepGC"); |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
47216
diff
changeset
|
89 |
} |
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
90 |
} |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
91 |
|
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
92 |
/* |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
93 |
* Creating command-line for running subprocess JVM: |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
94 |
* |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
95 |
* JVM command line is like: |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
96 |
* {test_jdk}/bin/java {defaultopts} -cp {test.class.path} {testopts} main |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
97 |
* |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
98 |
* {defaultopts} are the default java options set by the framework. |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
99 |
* |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
100 |
* @param testOpts java options specified by the test. |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
101 |
*/ |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
102 |
private static List<String> buildCommandLine(String... testOpts) { |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
103 |
List<String> opts = new ArrayList<>(); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
104 |
opts.add(JDKToolFinder.getJDKTool("java")); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
105 |
opts.addAll(Arrays.asList(Utils.getTestJavaOpts())); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
106 |
opts.add("-cp"); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
107 |
opts.add(System.getProperty("test.class.path", "test.class.path")); |
35246 | 108 |
opts.add("-Xlog:gc*=debug"); |
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
109 |
opts.addAll(Arrays.asList(testOpts)); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
110 |
opts.add(classMain); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
111 |
|
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
112 |
return opts; |
23933
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
113 |
} |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
114 |
|
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
115 |
/** |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
116 |
* Runs LowMemoryTest$TestMain with the passed options and redirects subprocess |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
117 |
* standard I/O to the current (parent) process. This provides a trace of what |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
118 |
* happens in the subprocess while it is runnning (and before it terminates). |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
119 |
* |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
120 |
* @param prefixName the prefix string for redirected outputs |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
121 |
* @param testOpts java options specified by the test. |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
122 |
*/ |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
123 |
private static void traceTest(String prefixName, |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
124 |
String... testOpts) |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
125 |
throws Throwable { |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
126 |
|
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
127 |
// Building command-line |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
128 |
List<String> opts = buildCommandLine(testOpts); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
129 |
|
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
130 |
// We activate all tracing in subprocess |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
131 |
opts.add("trace"); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
132 |
|
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
133 |
// Launch separate JVM subprocess |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
134 |
String[] optsArray = opts.toArray(new String[0]); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
135 |
ProcessBuilder pb = new ProcessBuilder(optsArray); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
136 |
System.out.println("\n========= Tracing of subprocess " + prefixName + " ========="); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
137 |
Process p = ProcessTools.startProcess(prefixName, pb); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
138 |
|
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
139 |
// Handling end of subprocess |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
140 |
try { |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
141 |
int exitCode = p.waitFor(); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
142 |
if (exitCode != 0) { |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
143 |
throw new RuntimeException( |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
144 |
"Subprocess unexpected exit value of [" + exitCode + "]. Expected 0.\n"); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
145 |
} |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
146 |
} catch (InterruptedException e) { |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
147 |
throw new RuntimeException("Parent process interrupted with exception : \n " + e + " :" ); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
148 |
} |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
149 |
|
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
150 |
|
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
151 |
} |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
152 |
|
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
153 |
private static volatile boolean listenerInvoked = false; |
2 | 154 |
static class SensorListener implements NotificationListener { |
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
155 |
@Override |
2 | 156 |
public void handleNotification(Notification notif, Object handback) { |
157 |
String type = notif.getType(); |
|
158 |
if (type.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED) || |
|
159 |
type.equals(MemoryNotificationInfo. |
|
160 |
MEMORY_COLLECTION_THRESHOLD_EXCEEDED)) { |
|
161 |
||
162 |
MemoryNotificationInfo minfo = MemoryNotificationInfo. |
|
163 |
from((CompositeData) notif.getUserData()); |
|
164 |
||
165 |
MemoryUtil.printMemoryNotificationInfo(minfo, type); |
|
166 |
listenerInvoked = true; |
|
167 |
} |
|
168 |
} |
|
169 |
} |
|
170 |
||
171 |
static class TestListener implements NotificationListener { |
|
28245
5560f8810064
8034263: Test java/lang/management/MemoryMXBean/LowMemoryTest.java fails intermittently
jbachorik
parents:
26459
diff
changeset
|
172 |
private boolean isRelaxed = false; |
2 | 173 |
private int triggers = 0; |
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
174 |
private final long[] count = new long[NUM_TRIGGERS * 2]; |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
175 |
private final long[] usedMemory = new long[NUM_TRIGGERS * 2]; |
28245
5560f8810064
8034263: Test java/lang/management/MemoryMXBean/LowMemoryTest.java fails intermittently
jbachorik
parents:
26459
diff
changeset
|
176 |
|
5560f8810064
8034263: Test java/lang/management/MemoryMXBean/LowMemoryTest.java fails intermittently
jbachorik
parents:
26459
diff
changeset
|
177 |
public TestListener() { |
5560f8810064
8034263: Test java/lang/management/MemoryMXBean/LowMemoryTest.java fails intermittently
jbachorik
parents:
26459
diff
changeset
|
178 |
isRelaxed = ManagementFactory.getRuntimeMXBean().getInputArguments().contains("-XX:+UseConcMarkSweepGC"); |
5560f8810064
8034263: Test java/lang/management/MemoryMXBean/LowMemoryTest.java fails intermittently
jbachorik
parents:
26459
diff
changeset
|
179 |
} |
5560f8810064
8034263: Test java/lang/management/MemoryMXBean/LowMemoryTest.java fails intermittently
jbachorik
parents:
26459
diff
changeset
|
180 |
|
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
181 |
@Override |
2 | 182 |
public void handleNotification(Notification notif, Object handback) { |
183 |
MemoryNotificationInfo minfo = MemoryNotificationInfo. |
|
184 |
from((CompositeData) notif.getUserData()); |
|
185 |
count[triggers] = minfo.getCount(); |
|
186 |
usedMemory[triggers] = minfo.getUsage().getUsed(); |
|
187 |
triggers++; |
|
188 |
} |
|
189 |
public void checkResult() throws Exception { |
|
29029
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
190 |
if (!checkValue(triggers, NUM_TRIGGERS)) { |
2 | 191 |
throw new RuntimeException("Unexpected number of triggers = " + |
192 |
triggers + " but expected to be " + NUM_TRIGGERS); |
|
193 |
} |
|
194 |
||
195 |
for (int i = 0; i < triggers; i++) { |
|
29029
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
196 |
if (!checkValue(count[i], i + 1)) { |
2 | 197 |
throw new RuntimeException("Unexpected count of" + |
198 |
" notification #" + i + |
|
199 |
" count = " + count[i] + |
|
200 |
" but expected to be " + (i+1)); |
|
201 |
} |
|
202 |
if (usedMemory[i] < newThreshold) { |
|
203 |
throw new RuntimeException("Used memory = " + |
|
204 |
usedMemory[i] + " is less than the threshold = " + |
|
205 |
newThreshold); |
|
206 |
} |
|
207 |
} |
|
208 |
} |
|
29029
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
209 |
|
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
210 |
private boolean checkValue(int value, int target) { |
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
211 |
return checkValue((long)value, target); |
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
212 |
} |
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
213 |
|
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
214 |
private boolean checkValue(long value, int target) { |
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
215 |
if (!isRelaxed) { |
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
216 |
return value == target; |
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
217 |
} else { |
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
218 |
return value >= target; |
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
219 |
} |
433de2a38271
8069286: Unexpected count of notification in LowMemoryTest
jbachorik
parents:
28528
diff
changeset
|
220 |
} |
2 | 221 |
} |
222 |
||
223 |
private static long newThreshold; |
|
224 |
||
23933
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
225 |
private static class TestMain { |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
226 |
public static void main(String args[]) throws Exception { |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
227 |
if (args.length > 0 && args[0].equals("trace")) { |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
228 |
trace = true; |
2 | 229 |
} |
230 |
||
23933
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
231 |
// Find the Old generation which supports low memory detection |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
232 |
ListIterator iter = pools.listIterator(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
233 |
while (iter.hasNext()) { |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
234 |
MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
235 |
if (p.getType() == MemoryType.HEAP && |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
236 |
p.isUsageThresholdSupported()) { |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
237 |
mpool = p; |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
238 |
if (trace) { |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
239 |
System.out.println("Selected memory pool for low memory " + |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
240 |
"detection."); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
241 |
MemoryUtil.printMemoryPool(mpool); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
242 |
} |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
243 |
break; |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
244 |
} |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
245 |
} |
2 | 246 |
|
23933
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
247 |
TestListener listener = new TestListener(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
248 |
SensorListener l2 = new SensorListener(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
249 |
NotificationEmitter emitter = (NotificationEmitter) mm; |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
250 |
emitter.addNotificationListener(listener, null, null); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
251 |
emitter.addNotificationListener(l2, null, null); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
252 |
|
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
253 |
Thread allocator = new AllocatorThread(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
254 |
Thread sweeper = new SweeperThread(); |
2 | 255 |
|
26459
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
256 |
// The chunk size needs to be larger than YOUNG_GEN_SIZE, |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
257 |
// otherwise we will get intermittent failures when objects |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
258 |
// end up in the young gen instead of the old gen. |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
259 |
final long epsilon = 1024; |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
260 |
chunkSize = YOUNG_GEN_SIZE + epsilon; |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
261 |
|
23933
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
262 |
MemoryUsage mu = mpool.getUsage(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
263 |
newThreshold = mu.getUsed() + (chunkSize * NUM_CHUNKS); |
2 | 264 |
|
26459
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
265 |
// Sanity check. Make sure the new threshold isn't too large. |
25999
1e494b91a5a5
8035939: java/lang/management/MemoryMXBean/MemoryManagement.java timed out on Linux-amd64
stefank
parents:
24366
diff
changeset
|
266 |
// Tweak the test if this fails. |
26459
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
267 |
final long headRoom = chunkSize * 2; |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
268 |
final long max = mu.getMax(); |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
269 |
if (max != -1 && newThreshold > max - headRoom) { |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
270 |
throw new RuntimeException("TEST FAILED: newThreshold: " + newThreshold + |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
271 |
" is too near the maximum old gen size: " + max + |
fa5576f930e6
8057174: MemoryMXBean tests -- TEST FAILED: chunkSize: 6291456 is less than YOUNG_GEN_SIZE: 8388608
stefank
parents:
25999
diff
changeset
|
272 |
" used: " + mu.getUsed() + " headRoom: " + headRoom); |
25999
1e494b91a5a5
8035939: java/lang/management/MemoryMXBean/MemoryManagement.java timed out on Linux-amd64
stefank
parents:
24366
diff
changeset
|
273 |
} |
1e494b91a5a5
8035939: java/lang/management/MemoryMXBean/MemoryManagement.java timed out on Linux-amd64
stefank
parents:
24366
diff
changeset
|
274 |
|
23933
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
275 |
System.out.println("Setting threshold for " + mpool.getName() + |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
276 |
" from " + mpool.getUsageThreshold() + " to " + newThreshold + |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
277 |
". Current used = " + mu.getUsed()); |
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
278 |
|
23933
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
279 |
mpool.setUsageThreshold(newThreshold); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
280 |
|
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
281 |
if (mpool.getUsageThreshold() != newThreshold) { |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
282 |
throw new RuntimeException("TEST FAILED: " + |
2 | 283 |
"Threshold for Memory pool " + mpool.getName() + |
284 |
"is " + mpool.getUsageThreshold() + " but expected to be" + |
|
285 |
newThreshold); |
|
23933
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
286 |
} |
2 | 287 |
|
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
288 |
|
23933
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
289 |
allocator.start(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
290 |
// Force Allocator start first |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
291 |
phaser.arriveAndAwaitAdvance(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
292 |
sweeper.start(); |
2 | 293 |
|
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
294 |
|
23933
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
295 |
try { |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
296 |
allocator.join(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
297 |
// Wait until AllocatorThread's done |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
298 |
phaser.arriveAndAwaitAdvance(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
299 |
sweeper.join(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
300 |
} catch (InterruptedException e) { |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
301 |
System.out.println("Unexpected exception:" + e); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
302 |
testFailed = true; |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
303 |
} |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
304 |
|
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
305 |
listener.checkResult(); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
306 |
|
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
307 |
if (testFailed) |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
308 |
throw new RuntimeException("TEST FAILED."); |
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
309 |
|
754ee146b623
8030628: Update java/lang/management/MemoryMXBean tests to ignore GC setting by jtreg
mtobiass
parents:
22075
diff
changeset
|
310 |
System.out.println(RunUtil.successMessage); |
2 | 311 |
} |
312 |
} |
|
313 |
||
314 |
private static void goSleep(long ms) { |
|
315 |
try { |
|
316 |
Thread.sleep(ms); |
|
317 |
} catch (InterruptedException e) { |
|
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
318 |
System.out.println("Unexpected exception:" + e); |
2 | 319 |
testFailed = true; |
320 |
} |
|
321 |
} |
|
322 |
||
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
323 |
private static final List<Object> objectPool = new ArrayList<>(); |
2 | 324 |
static class AllocatorThread extends Thread { |
325 |
public void doTask() { |
|
326 |
int iterations = 0; |
|
327 |
int numElements = (int) (chunkSize / 4); // minimal object size |
|
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
328 |
while (!listenerInvoked || mpool.getUsage().getUsed() < mpool.getUsageThreshold()) { |
2 | 329 |
iterations++; |
330 |
if (trace) { |
|
331 |
System.out.println(" Iteration " + iterations + |
|
332 |
": before allocation " + |
|
333 |
mpool.getUsage().getUsed()); |
|
334 |
} |
|
335 |
||
336 |
Object[] o = new Object[numElements]; |
|
337 |
if (iterations <= NUM_CHUNKS) { |
|
338 |
// only hold a reference to the first NUM_CHUNKS |
|
339 |
// allocated objects |
|
340 |
objectPool.add(o); |
|
341 |
} |
|
342 |
||
343 |
if (trace) { |
|
344 |
System.out.println(" " + |
|
345 |
" after allocation " + |
|
346 |
mpool.getUsage().getUsed()); |
|
347 |
} |
|
348 |
goSleep(100); |
|
349 |
} |
|
350 |
} |
|
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
351 |
@Override |
2 | 352 |
public void run() { |
353 |
for (int i = 1; i <= NUM_TRIGGERS; i++) { |
|
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
354 |
// Sync with SweeperThread's second phase. |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
355 |
phaser.arriveAndAwaitAdvance(); |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
356 |
System.out.println("AllocatorThread is doing task " + i + |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
357 |
" phase " + phaser.getPhase()); |
2 | 358 |
doTask(); |
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
359 |
// Sync with SweeperThread's first phase. |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
360 |
phaser.arriveAndAwaitAdvance(); |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
361 |
System.out.println("AllocatorThread done task " + i + |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
362 |
" phase " + phaser.getPhase()); |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
363 |
if (testFailed) { |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
364 |
return; |
2 | 365 |
} |
366 |
} |
|
367 |
} |
|
368 |
} |
|
369 |
||
370 |
static class SweeperThread extends Thread { |
|
371 |
private void doTask() { |
|
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
372 |
int iterations = 0; |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
373 |
if (trace) { |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
374 |
System.out.println("SweeperThread clearing allocated objects."); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
375 |
} |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
376 |
|
2 | 377 |
for (; mpool.getUsage().getUsed() >= |
378 |
mpool.getUsageThreshold();) { |
|
379 |
// clear all allocated objects and invoke GC |
|
380 |
objectPool.clear(); |
|
381 |
mm.gc(); |
|
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
382 |
|
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
383 |
if (trace) { |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
384 |
iterations++; |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
385 |
System.out.println("SweeperThread called " + iterations + |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
386 |
" time(s) MemoryMXBean.gc()."); |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
387 |
} |
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
388 |
|
2 | 389 |
goSleep(100); |
390 |
} |
|
391 |
} |
|
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
392 |
|
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
393 |
@Override |
2 | 394 |
public void run() { |
395 |
for (int i = 1; i <= NUM_TRIGGERS; i++) { |
|
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
396 |
// Sync with AllocatorThread's first phase. |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
397 |
phaser.arriveAndAwaitAdvance(); |
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
398 |
System.out.println("SweeperThread is doing task " + i + |
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
399 |
" phase " + phaser.getPhase()); |
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
400 |
|
2 | 401 |
doTask(); |
402 |
||
403 |
listenerInvoked = false; |
|
404 |
||
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
405 |
// Sync with AllocatorThread's second phase. |
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
406 |
phaser.arriveAndAwaitAdvance(); |
32103
252be3ad6800
8130339: Add tracing info to LowMemoryTest.java to help 8130339 diagnosis
olagneau
parents:
30376
diff
changeset
|
407 |
System.out.println("SweeperThread done task " + i + |
22075
4c204174a8d9
8029346: LowMemoryTestConcMarkSweepGC.sh fails intermittently with timeout
mchung
parents:
7668
diff
changeset
|
408 |
" phase " + phaser.getPhase()); |
2 | 409 |
if (testFailed) return; |
410 |
} |
|
411 |
} |
|
412 |
} |
|
413 |
} |