-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
JVM Metaspace keeps growing with @RequestScope
, AOP and @Validated
because of proxying.
#27395
Comments
Looks like the CGLIB proxy class leak to be fixed by this PR that we're about to merge for 5.3.10: #27375 |
Closing this one based on the assumption that #27375 covers your scenario as well. Please give the 5.3.10 release a try, it's available in snapshots already and will be officially released tomorrow! |
Yep yep yep, behavior is normal with ❯ for i in (seq 0 50); curl -s localhost:8080/hey >> /dev/null ; end ;and jmap -clstats (ps aux |grep java | grep "demo/out" | tr -s " " | cut -d " " -f2)| grep -i demo.controller
1385 3912 48 936 0 6128 52 2159 9808 6880 11352 18232 com.example.demo.Controller$$EnhancerBySpringCGLIB$$a08aa040
1750 7809 32 656 0 1464 7 484 1544 1160 2704 3864 com.example.demo.Controller$$FastClassBySpringCGLIB$$fdcabab6
2439 7809 16 656 0 5712 7 3962 5016 5104 6480 11584 com.example.demo.Controller$$EnhancerBySpringCGLIB$$7ccbe311$$FastClassBySpringCGLIB$$69fd863c
2440 7809 16 656 0 6072 7 4248 5312 5440 6800 12240 com.example.demo.Controller$$EnhancerBySpringCGLIB$$a08aa040$$FastClassBySpringCGLIB$$a1a0be46
3912 13 0 536 112 520 2 8 368 400 1280 1680 com.example.demo.Controller
3913 3912 0 904 0 5584 48 1947 9000 6184 10464 16648 com.example.demo.Controller$$EnhancerBySpringCGLIB$$7ccbe311 👍🏼 thanks |
Good to hear, thanks for the immediate feedback! |
Affects: spring-framework >= v5.3.1
Problem:
The JVM Metaspace keeps growing with each call to a controller and after a while the JVM crashes. It is linked to the fact that new class definitions are created without being deleted for proxies around controllers.
How to reproduce:
The problem occurs when you have a controller :
@RequestScope
or@SessionScope
@Validated
Here is a sample Spring Boot app that exhibits the problem :
If you launch a couple of requests to the endpoint, you can witness that a large number of proxy class definitions are added to the Metaspace.
(this is fish shell, but the bash equivalent should be straightforward, I'm just sending 50 requests, then getting the PID of the Spring app and querying the loaded classes definitions)
Result :
We discovered this problem on a large scale application when we updated Spring from
5.2.15.RELEASE
to5.3.9
. As I said, the phenomenon causes Metaspace to grow until JVM crashes.I tried with different versions of Spring and found out that
5.3.0
is OK but there is a problem with5.3.1
. So my guess is that it is linked to this commit : 10bff05 and this issue : #26019. But I might be wrong, my knowledge on this topic is very limited :)Here is the build.gradle.kts used for the demo project (
spring boot 2.4.0
->spring 5.3.1
) :Forcing spring to
5.3.0
fixes the behaviour :Gives the following result :
I also tried removing the aspect, or the
@Validated
on the controller, or the@RequestScope
and each of these modifications fixes the problem. Unfortunately, it is not so simple on our real life application...Do not hesitate to ask for more info !
Cheers,
Julien
The text was updated successfully, but these errors were encountered: