spring-framework: Memory leak when using @Async after upgrading from 5.1 to 5.2
Affects: 5.2.0.RC1
In our application I upgraded from spring-framework 5.1.9 to 5.2.0.RC1 and our tests started leaking memory.
Previously it looked like this in VisualVM:

And now it looks like this:

I’ve made a heapdump to see where the memory is going:

I’ve seen something similar in our application previously, but that was solved by using @MockBean instead of a lot of @ContextConfiguration with @Configuration classes inside our test classes to override beans with mocked objects 🤔…
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (11 by maintainers)
Commits related to this issue
- Ensure ClassFilter and MethodMatcher implementations are cacheable While resolving the regression raised in gh-23571, it came to our attention that not all of our ClassFilter and MethodMatcher implem... — committed to sbrannen/spring-framework by sbrannen 7 years ago
- Ensure ClassFilter and MethodMatcher implementations are cacheable While resolving the regression raised in gh-23571, it came to our attention that not all of our ClassFilter and MethodMatcher implem... — committed to spring-projects/spring-framework by sbrannen 7 years ago
With that it seems to work without leaks.
Great!
Mystery solved: the newly introduced
AnnotationMatchingPointcut.AnnotationCandidateClassFilterclass doesn’t implementequals().I’ve got a fix locally that I’ll apply tomorrow to
master.