[ 
https://issues.apache.org/jira/browse/GROOVY-12142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18105190#comment-18105190
 ] 

Paul King commented on GROOVY-12142:
------------------------------------

It seems like we didn't document the option meant for cases like yours: use 
-Dgroovy.use.classvalue=false on the Tomcat JVM (JVM-wide, per-webapp Groovy 
copies each honor it).

As an alterbative, add a ServletContextListener.contextDestroyed that calls 
ClassInfo.remove(c) for every ClassInfo.getAllClassInfo() entry — the public 
API's javadoc even names this use case.

Unfortunately, looks like the option was "cleaned up" along with some other 
changes for Groovy 5/6. I'm looking at what is involved in reinstating that 
functionality.

> Metaspace memory leak with parallel deployments on Tomcat
> ---------------------------------------------------------
>
>                 Key: GROOVY-12142
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12142
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.24, 4.0.29, 5.0.8, 5.1.0, 6.0.0-beta-2
>         Environment: Tomcat: 10.1.55
> openjdk version "17.0.19" 2026-04-21 LTS
> OpenJDK Runtime Environment (Red_Hat-17.0.19.0.10-1) (build 17.0.19+10-LTS)
> OpenJDK 64-Bit Server VM (Red_Hat-17.0.19.0.10-1) (build 17.0.19+10-LTS, 
> mixed mode, sharing)
>            Reporter: Jan Gosmann
>            Assignee: Paul King
>            Priority: Major
>         Attachments: Screenshot 2026-07-09 at 09.46.46.png, spring-test.tar.gz
>
>
> We are using [Tomcat parallel 
> deployments|https://tomcat.apache.org/tomcat-10.0-doc/config/context.html#Parallel_deployment]
>  to achieve downtimeless deployments. However, we with each new deployment 
> the metaspace grows (see attached image). Even after undeploying the old 
> version it does not shrink. If we configure a maximum metaspace size, new 
> parallel deployments fail with an out-of-memory error.
> I was able to reproduce this with a very simple Spring Boot application 
> (attached). As long as I had no Groovy in there, metaspace was reclaimed 
> before hitting the maximum on new deploys. After introducing Groovy, 
> metaspace is no longer reclaimed.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to