apache / apache/maven-checkstyle-plugin

[MCHECKSTYLE-457] memory leak in checkstyle plugin

Open
#368 6 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
97
Forks
67
Avg merge
14h 50m
Merged PRs (30d)
6

Description

**[James Nord](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jnord_cbs)** opened **[MCHECKSTYLE-457](https://issues.apache.org/jira/browse/MCHECKSTYLE-457?redirect=false)** and commented

memory used by checkstyle:check mojo is not released after the mojo completes its analysis.

In a build on [Jenkins](https://github.com/jenkinsci/jenkins/) an analysis of a heapdump shows that there is 180+MB retained by the JavaLanguageParser

!image-2025-04-11-12-55-18-038.png|thumbnail!

After the invocation of the mojo it is expected that memory would be relinquished.

### Steps to reproduce

* clone https://github.com/jenkinsci/jenkins/
* switch to the `jenkins-2.504` branch
* edit `.mvn/jvm.config` so it contains the following (to force running out of memory and providing a heap dump):

```
-Xmx500M
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=D:\source\github\cloudbees\private-jenkins
```

* run `mvn clean verify -DskipTests`

### Expected results

500M should be enough to build, or if the build fails due to memory there is no memory held by mojos (for part of their actions) that have completed.

### Actual Results

the build fails producing the war in the maven-war-plugin (in the war project).
Inspection of the heap shows 180MB in use by com.puppycrawl.tools.checkstyle.grammar.java.JavaLanguageParser classloaders

---

**Affects:** 3.6.0

**Attachments:**
- [image-2025-04-11-12-55-18-038.png](https://issues.apache.org/jira/secure/attachment/13075950/image-2025-04-11-12-55-18-038.png) (_157.49 kB_)
- [screenshot-1.png](https://issues.apache.org/jira/secure/attachment/13075951/screenshot-1.png) (_100.34 kB_)

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the leak by building Jenkins at the jenkins-2.504 branch with the provided JVM settings and mvn clean verify -DskipTests. Investigate the checkstyle:check mojo and retained JavaLanguageParser classloaders; done means completed mojos no longer retain that memory and the build can complete within the stated memory limit.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.