spring-framework
spring-framework copied to clipboard
Fix memory leak with CglibAopProxy$ProxyCallbackFilter
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
advisorsandadvisorChainFactoryWeakReference , 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
AbstractAutoProxyCreatorimplementsDisposableBean, clearCallbackFilterfield in generated class.