-
Notifications
You must be signed in to change notification settings - Fork 41.2k
JarFile can cause memory issues when running on Java 11+ #22991
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
Comments
Thanks for the sample application, it's been very helpful. My initial thoughts are that commit From the profiler, it looks like I'm really not sure how we can fix this one and also keep the fix for #17796. The only idea I've had so far is to create a new We'll need to do some experiments. |
@alexey-anufriev I think I may have a fix for this, but I'm not 100% confident. If you get the chance, could you please try |
@philwebb, I have already tried the same app with In any case, thank you for the resolution, and I will keep you updated after I get this version live (but it will take me some time). |
Refine method visibility in an attempt to fix test issues on Java 11+. See gh-22991
Remove Mockto from JarFileWrapperTests since it seems to be failing on later versions of Java. See gh-22991
Update `JarFileWrapperTests` so that the jar files are closed after each test. See gh-22991
Description
After upgrade from Spring Boot 2.2.6 to 2.2.7 application started consuming much more memory.
In particular Heap Dump shows significantly higher number of instances of type:
org.springframework.boot.loader.jar.JarFile
.Heap Dump (v2.2.6) is here.

It contains the following number of instances:
Heap Dump (v2.2.7) is here.

It contains the following number of instances:
The number of instances is significantly higher.
Reason
After checking the history of related changes there is a couple of commits that worth to be checked:
Create new JarFile instance for URL connections
Attempt to prevent JarFiles from being left open
Attempt to prevent JarFiles from being left open
Steps to reproduce
The following repository can be used:
https://github.com/alexey-anufriev/spring-boot-2.2.7-memory-leak#steps-to-reproduce
The text was updated successfully, but these errors were encountered: