- Notifications
You must be signed in to change notification settings - Fork 38.9k
Description
I am currently trying to resolve an issue we're seeing with redeploying a spring boot application that looks to be a problem in the spring boot end not ours?
Links:
- Stack overflow question: https://stackoverflow.com/questions/70174850/spring-boot-tomcat-redeploy-permgen-leak-due-to-logging
- Git repo: https://github.com/webbres/spring-boot-permgen-issue/tree/master/debugging
Config:
Java 11
OS: Windows & Centos
Spring boot: 2.5
Tomcat: 9.0.27
The problem/bug:
When deploying on tomcat 9 using java 11 reloading an application results in a PermGen memory leak with the classloader for the application not being GCd. After adding additional configuration only weak and soft references are found in the heap.
Summary of findings:
Reloading a spring boot application deployed as a war in tomcat 9 results in a PermGen memory leak (reported by the find leaks check and checked in VisualVM). In our actual application there is a strong reference to a log4j JMX bean which is removed when running tomcat with -Dlog4j2.disable.jmx=true though even then the org.apache.catalina.loader.ParallelWebappClassLoader for the application is marked as DESTROYED but is not garbage collected.
I attempted to recreate the issue on a simple spring boot starter (see repo linked). Here I found strong references to logging shutdown hooks which are removed when adding logging.register-shutdown-hook=false to the application.properties. Though after adding this property like above the classloader still isn't being garbage collected.
Cheers
Sam