Bug #69362 Abandoned load-balanced connections cause memory leak
Submitted: 31 May 2013 8:20
Reporter: Alexander Soklakov Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.x OS:Any
Assigned to: Alexander Soklakov CPU Architecture:Any

[31 May 2013 8:20] Alexander Soklakov
Description:
Load-balanced/failover connections cause memory leak if were not closed explicitly.

AbandonedConnectionCleanupThread should take care about such connections, but the problem is that refQueue keeps references to underlying ConnectionImpls not to the top object (LoadBalancingConnectionProxy eg.). So when application lost reference to the top connection object this object remains in strong references from ConnectionImpls and at the same time keeps strong references to these objects.

How to repeat:
Make a loop with steps:
1) create l-b connection;
2) assign null to this connection reference

Suggested fix:
1) Pass l-b object to NonRegisteringDriver.trackConnection(Connection newConn) instead of ConnectionImpls
2) Keep reference from ConnectionImpl to proxy as WeakReference.