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:

image

And now it looks like this:

image

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

image

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

Most upvoted comments

@arian, can you confirm that executing your test suite with -Dcglib.useCache=false works without a memory leak?

With that it seems to work without leaks.

Mystery solved

Great!

Mystery solved: the newly introduced AnnotationMatchingPointcut.AnnotationCandidateClassFilter class doesn’t implement equals().

I’ve got a fix locally that I’ll apply tomorrow to master.