Re: useCompression=true and potential Memory leak due to connection tracking via CompressionInputStreamMemoryLeak
Posted by: Dominic Tootell
Date: May 13, 2013 11:31AM


Thank you for the update. Please let me know if you need any more information.

>> Just one note about your test. You can reach "too many connections"
>> situation even without compression and also with WeakReference patch if you
>> create references faster then AbandonedConnectionCleanupThread cleanups them.

Yup absolutley agree, and is the reason why I updated my local mysql instance to have 3000 as the max_connections setting when running without the connection.close().

I suspect the best way to tackle this would be to make a batch of connections (countMany(100)), then run the method that just creates garbage, sleep the main thread for a little, and then loop 20 times, rather than doing the countMany(2000). This would at least mean the Connection would have been Reference queued for the AbandonedConnectionCleanupThread due to the GC method (if the bug didn't exist). You'd still need 2500+ connections, to get the OOM with -Xmx100m

Again, thank you for the quick feedback.


Apologies, I forgot to ask a question regarding the trackConnection in the ConnectionImpl constructor.

Would it be possible to make a change such that you can 'opt-out' of Connection Tracking i.e. connectionTracking=true|false on the jdbc url perhaps?... If the application developer knows that the application calls Connection.close() is all circumstances, then the management of the PhantomReference's is just overhead for the GC of the client application; with more live objects for it to manage. For those applications where the connections are managed by the application server or a similar connection pool (tomcat pool, bonecp), then connection.close is called by that external component, and in theory no connection tracking should be needed to make sure connection.close is called.


Edited 1 time(s). Last edit at 05/13/2013 02:53PM by Dominic Tootell.

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.