spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Fix memory leak with CglibAopProxy$ProxyCallbackFilter

Open vikeychen opened this issue 3 years ago • 0 comments

Bug report

Bug report and reason is explained very well here #26266.

In the cglib side, this issue #80 is the consequence of trying to solve CallbackFilter leak. As vlsi said

"weakly reachable CallbackFilters" and "classloader reuse" do not play together well.

Solution

  • This solution is to try to reduce the leak by make advisors and advisorChainFactory WeakReference , so that there should have no chance to leak 'big object'. Think about class created by cglib is also 'leaked', I think that should be acceptable.

  • Another quick solution is to make AbstractAutoProxyCreator implements DisposableBean, clear CallbackFilter field in generated class.

vikeychen avatar Jul 29 '22 16:07 vikeychen