[ https://issues.apache.org/jira/browse/MCHECKSTYLE-457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17943551#comment-17943551 ]
Roman Ivanov commented on MCHECKSTYLE-457: ------------------------------------------ JavaLanguageParser is class generated by ANTLR. we do not have any explicit cleanup, and we rely on GC to cleanup classes after it is finished to be used. Java parser exists only in TreeWalker checkstyle module https://checkstyle.sourceforge.io/config.html#TreeWalker , so it is configuration of checkstyle. So I presume, configuration classes are continue to be valid and accessible and GC is not cleanup them. > memory leak in checkstyle plugin > -------------------------------- > > Key: MCHECKSTYLE-457 > URL: https://issues.apache.org/jira/browse/MCHECKSTYLE-457 > Project: Maven Checkstyle Plugin > Issue Type: Bug > Components: checkstyle:check > Affects Versions: 3.6.0 > Environment: Apache Maven 3.9.9 > (8e8579a9e76f7d015ee5ec7bfcdc97d260186937) > Maven home: c:\Java\maven-3.9.9 > Java version: 21.0.1, vendor: Eclipse Adoptium, runtime: > c:\Java\jdk-21.0.1.12-hotspot > Reporter: James Nord > Priority: Major > Attachments: image-2025-04-11-12-55-18-038.png, screenshot-1.png > > > 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. > h3. 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): > {code} > -Xmx500M > -XX:+HeapDumpOnOutOfMemoryError > -XX:HeapDumpPath=D:\source\github\cloudbees\private-jenkins > {code} > * run {{mvn clean verify -DskipTests}} > h3. 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. > h3. 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 > -- This message was sent by Atlassian Jira (v8.20.10#820010)