Affects: 5.2.8
First of all, sorry for my bad english. If you're hard to understand my sentence, please comment
Ive been testing my team's project and monitoring it with scouter
APM.
And found that "used heap" keeps going high whenever I call an different API .
I debugged and found that Spring
accumulates ResponseEntity
in ConcurrentReferenceHashMap
of ResolvableType.cache
.
It puts the whole response body of each ResponseEntity
in ConcurrentReferenceHashMap
which is static.
I believe that the Spring developers intended it for some reasons but I cannot find any even if I googled a lot.
If It it's an issue , please fix this.
if it's not, I would very appreciate you for giving me some explanation why Spring
accumulates the ResponseEntity
objects
even if it has a BIG BIG body.
Thank you. Best Regard.
Comment From: snicoll
@KangChanSong the cache that you mention is a cache of resolvable types. ResolvableType
does not have a link to ResponseEntity
so I am afraid I don't understand the report. Can you point to the code that you believe is caching ResponseEntity
objects?
Comment From: KangChanSong
This is a stack trace where ResponseEntity
object is cached in to ConcurrentReferenceHashMap
And another screenshot of a ResponseEntity object and its incoming reference tree
Comment From: snicoll
I can see that we have a MethodParameter
implementation, ReturnValueMethodParameter
, that keeps a reference to the actual return value. Spring HATEOAS seems to be using ResolvableType#forMethodParameter
passing the actual MethodParameter
implementation.
If the type is using MethodParameterTypeProvider
I can see how that could have the side effect of keeping the return value in the cache there.
Comment From: jhoeller
Indeed, and ReturnValueMethodParameter
does not even do anything with the value itself, just obtaining the return value type on demand. Let's change this to a ReturnTypeMethodParameter
that just holds on to the pre-determined value type.