You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Todd Carmichael <to...@concur.com> on 2004/03/03 18:01:02 UTC

[DBCP] Very small memory leak

Our 12 and 24 hour stress tests (300 concurrent users inserting lots of
data)  were running out of memory after about 8+ hours.  After some tests we
determined that it was DBCP.  This determination was made by switching out
the commons connection pooling and using an application server (Weblogic
8.1) connection pooling.  Using the application server connection pooling
memory was not leaked.  So doing some debugging with some long running tests
in my dev environment (using OptimizeIt), I determined that the
KeyedCPDSConnectionFactory.java was leaking memory with the WeakHashMap
(class member pcMap).  I don't understand why this should leak because the
jdk documentation indicates that the keys in the map are weak referenced and
when the keys are removed, the object is removed from the map.  Nonetheless,
I made the following code change (diff is in attachment) and reran my dev
tests and no leak occurred and we reran our stress tests in the performance
lab and no leak occurred there either.  Perhaps some version of the JDK is
causing this but I suspect others may run into this as well.  Included is a
patch that fixed our problem:  

 <<patch_memleak.txt>> 

ToddC