Re: useCompression=true and potential Memory leak due to connection tracking via CompressionInputStreamMemoryLeak
Posted by: Alexander Soklakov
Date: May 14, 2013 08:06AM

Hi Dominic,

Thanks! WeakReference is good. I updated patch in bug report http://bugs.mysql.com/bug.php?id=68400. It also contains regression test based on your idea to call GC and check map size after that but with some differences:
1) it creates connections by portions of 100 items then call garbage collector, sleep and check what left in NonRegisteringDriver.connectionPhantomRefs map
2) last half of connections are not properly closed to check that abandoned connections clean up also works
3) we don't want to reach OOM with regression test so we need some measure, I use connection attribute "testBug68400:true" (new feature in 5.1.25) to distinguish connections we test from other possible values in that map (it require some reflection since PhantomReference overrides get() method and always returns null); and the proper result is the absence of connections with such attribute after GC.

Dominic Tootell Wrote:
-------------------------------------------------------
> 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.

Yes, it's possible and sounds reasonable. Also this feature could help in some difficult situations when additional thread isn't welcome. Thank you for this suggestion too. You can fill the feature request at http://bugs.mysql.com or I can do it myself.

Thank you for all your help!

Alex.

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.