apache / apache/maven-surefire

[SUREFIRE-1147] Unbounded memory usage when running MANY tests

Open
#2,544 24 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

**[Laurent Claisse](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=chtimi59)** opened **[SUREFIRE-1147](https://issues.apache.org/jira/browse/SUREFIRE-1147?redirect=false)** and commented

I'm writing concurrency tests, checking that this thing is reproducible, that other thing isn't, and so on. So i repeat tests MANY times like 100_000 (to reproduce the leak, the test project is here: https://github.com/vandekeiser/parallel-stream-fork-join-pool)

I see in VisualVM that the culprit is WrappedReportEntry, which indirectly holds references to lots of byte[] and char[] (allocation traces and heap dump pics are included in attachment)

I forked and patched maven-surefire-common, and that makes the leak go. I had to replace WrappedReportEntry.original by a singleton fake ReportEntry.
Bebefore that i had replaced Utf8RecodingDeferredFileOutputStream.deferredFileOutputStream by a NullOutputStream and the leak was lesser but still here.

My fork of maven-surefire-common is there: https://github.com/vandekeiser/maven-surefire/tree/master/maven-surefire-common.
It IS a patch so i checked the patch checkbox in the issue reporter, but it is NOT intended to be distributed of course since it is very brutal and basic.

Also in my test project i explicitly deactivated reporting, but that doesn't make the reporting leak go away at all:
\true\
\false\

---

**Affects:** 2.18.1

**Attachments:**
- [newer.png](https://issues.apache.org/jira/secure/attachment/13039856/newer.png) (_313.66 kB_)
- [older.png](https://issues.apache.org/jira/secure/attachment/13039857/older.png) (_283.16 kB_)
- [surefire-allocation-traces.png](https://issues.apache.org/jira/secure/attachment/12720319/surefire-allocation-traces.png) (_136.66 kB_)
- [surefire-leak.png](https://issues.apache.org/jira/secure/attachment/12720159/surefire-leak.png) (_113.73 kB_)
- [surefire-leak2.png](https://issues.apache.org/jira/secure/attachment/12720362/surefire-leak2.png) (_113.21 kB_)
- [surefire-leak3.png](https://issues.apache.org/jira/secure/attachment/12720330/surefire-leak3.png) (_109.69 kB_)

2 votes, 8 watchers

Contributor guide

Open the contributing guide

Research direction

Start in the maven-surefire-common module, focusing on WrappedReportEntry and Utf8RecodingDeferredFileOutputStream, then reproduce the leak with the linked parallel-stream-fork-join-pool test project and heap-trace evidence. Done means identifying and correcting the retained references so repeated runs no longer show unbounded memory growth, with regression coverage for the reported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.