@Async with cglib based proxy causes memory leak in heap [SPR-11275] #15899
running mvn clean package && mvn exec:exec
Here is sample of stack trace:
Here is another stacktrace:
Stack traces differ from run to run depending where OOME was thrown. Sometimes exception isn't thrown but than in the console there are only logs of garbage collector activity
Here is the screenshot of the heap when OOME is about to be thrown
Affects: 3.2.6, 4.0 GA
Reference URL: https://github.com/lrozek/spring-leak
Backported to: 3.2.7
The text was updated successfully, but these errors were encountered:
Juergen Hoeller commented
After some digging, it turns out that the root cause is a missing equals/hashCode implementation in AnnotationMatchingPointcut. That generic pointcut class is rarely used within the framework, since we're using specific pointcut implementations in most cases.
However, Async processing does rely on AnnotationMatchingPointcut. Its lack of a proper 'equals' implementation prevented reuse of any affected proxy class in CGLIB, leading to recreation of identical proxy classes for every new context. Fixed for 4.0.1 and 3.2.7 now.