Skip to content

Commit 9643f65

Browse files
committed
8304436: com/sun/jdi/ThreadMemoryLeakTest.java fails with "OutOfMemoryError: Java heap space" with ZGC
8304449: com/sun/jdi/ThreadMemoryLeakTest.java times out Reviewed-by: lmesnik, dcubed
1 parent 69152c3 commit 9643f65

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

test/jdk/ProblemList-zgc.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,3 @@
2828
#############################################################################
2929

3030
java/util/concurrent/locks/Lock/OOMEInAQS.java 8298066 windows-x64
31-
32-
com/sun/jdi/ThreadMemoryLeakTest.java 8304436 generic-all

test/jdk/com/sun/jdi/ThreadMemoryLeakTest.java

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
* @requires (vm.compMode == "Xmixed")
3131
* @run build TestScaffold VMConnection TargetListener TargetAdapter
3232
* @run compile -g ThreadMemoryLeakTest.java
33-
* @comment run with -Xmx6m so any leak will quickly produce OOME
34-
* @run main/othervm -Xmx6m ThreadMemoryLeakTest
33+
* @comment run with -Xmx7m so any leak will quickly produce OOME
34+
* @run main/othervm -Xmx7m ThreadMemoryLeakTest
3535
*/
3636
import com.sun.jdi.*;
3737
import com.sun.jdi.event.*;
@@ -95,30 +95,23 @@ public static void main(String[] args) throws Exception {
9595

9696
/********** event handlers **********/
9797

98-
static int threadStartCount;
99-
static int threadDeathCount;
100-
private static List<ThreadReference> threads =
101-
Collections.synchronizedList(new ArrayList<ThreadReference>());
98+
static LongAdder threadStartCount = new LongAdder();
99+
static LongAdder threadDeathCount = new LongAdder();
102100

103101
public void threadStarted(ThreadStartEvent event) {
104-
threadStartCount++;
105-
if ((threadStartCount % 1000) == 0) {
102+
threadStartCount.increment();
103+
if ((threadStartCount.sum() % 1000) == 0) {
106104
println("Got ThreadStartEvent #" + threadStartCount +
107-
" threads:" + threads.size());
105+
" threads:" + (threadStartCount.sum() - threadDeathCount.sum()));
108106
}
109-
ThreadStartEvent tse = (ThreadStartEvent)event;
110-
threads.add(tse.thread());
111107
}
112108

113109
public void threadDied(ThreadDeathEvent event) {
114-
threadDeathCount++;
115-
if ((threadDeathCount % 1000) == 0) {
110+
threadDeathCount.increment();
111+
if ((threadDeathCount.sum() % 1000) == 0) {
116112
println("Got ThreadDeathEvent #" + threadDeathCount +
117-
" threads:" + threads.size());
113+
" threads:" + (threadStartCount.sum() - threadDeathCount.sum()));
118114
}
119-
ThreadDeathEvent tde = (ThreadDeathEvent)event;
120-
ThreadReference thread = tde.thread();
121-
threads.remove(thread);
122115
}
123116

124117
public void vmDied(VMDeathEvent event) {

0 commit comments

Comments
 (0)