Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.OutOfMemoryError: Metaspace when repeatedly deploying and undeploying a Spring Boot web application multiple times in Tomcat #37096

Closed
vazhaa72 opened this issue Aug 24, 2023 · 4 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@vazhaa72
Copy link

vazhaa72 commented Aug 24, 2023

When repeatedly deploying and undeploying a Spring Boot version 3.1.2 web application (WAR file) in a Tomcat application server one gets java.lang.OutOfMemoryError: Metaspace after 7-8 attempts.

This seems to be caused by the change in org.springframework.boot.SpringApplicationShutdownHook class, which now also registers org.springframework.boot.SpringApplicationShutdownHook.Handlers as a shut-down hook, which was not the case with Spring Boot 2.7 for example.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 24, 2023
@philwebb
Copy link
Member

It looks like we may have a regression that's re-introduced #27987

@philwebb philwebb added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 24, 2023
@philwebb philwebb added this to the 3.0.x milestone Aug 24, 2023
@philwebb
Copy link
Member

@vazhaa72 Have experienced the same problem with 3.0.x? I'm just wondering when we broke things.

@vazhaa72
Copy link
Author

vazhaa72 commented Aug 25, 2023

@vazhaa72 Have experienced the same problem with 3.0.x? I'm just wondering when we broke things.

@philwebb , I recompiled our projects with Spring Boot 3.0.0 and could not reproduce the issue. So I assume that a potential regression came in with 3.1.x.

@wilkinsona wilkinsona modified the milestones: 3.0.x, 3.1.x Aug 29, 2023
@mhalbritter mhalbritter changed the title java.lang.OutOfMemoryError: Metaspace when repeatedly deployng and undeploying a Spring Boot web application multiple times in Tomcat java.lang.OutOfMemoryError: Metaspace when repeatedly deploying and undeploying a Spring Boot web application multiple times in Tomcat Aug 30, 2023
@wilkinsona wilkinsona self-assigned this Sep 14, 2023
@wilkinsona
Copy link
Member

The regression is due to #34627. LoggingApplicationListener adds a shutdown handler which now causes the runtime shutdown hook to be added.

@vazhaa72, you can work around the problem by adding logging.register-shutdown-hook=false to application.properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants