Re: Memory leak with c3p0 using ConnectionProperties

Mark Matthews <[email protected]>
Newsgroups gmane.comp.db.mysql.java
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Achim Abeling wrote:
> Hi,
> 
> I think I found a memory leak in mysql-connector-3.1.11.
> 
> Perhaps the cause for the memory leak is in c3p0, but since the memory
> leak goes away when the JDBC url is changed I first post the problem here.
> 
> A class to reproduce the problem is attached.
> I am using mysql-connector-3.1.11 and c3p0 version 0.9.0 with JDK 1.5.0.
> 
> c3p0 has the possibility to expire idling connections. The test case
> sets an expire time of 1 second.
> The log shows that c3p0 really expires the connections and creates new
> connections.
> 
> When the JDBC url is
> "jdbc:mysql://localhost/test?profileSQL=true"
> the memory leak occurs, when it is
> "jdbc:mysql://localhost/test"
> it occurs not.
> 
> The memory leak can be observed by starting the class and then doing a
> # jmap -histo <processid> |grep "com.mysql.jdbc.Connection"
> 
> On my linux workstation it produces something like this:
> 
> Attaching to process ID 14539, please wait...
> Debugger attached successfully.
> Client compiler detected.
> JVM version is 1.5.0-b64
> Iterating over heap. This may take a while...
> 1180872 16401 com.mysql.jdbc.ConnectionProperties$BooleanConnectionProperty
> 277200  3465 com.mysql.jdbc.ConnectionProperties$IntegerConnectionProperty
> 182952  2541   
> com.mysql.jdbc.ConnectionProperties$StringConnectionProperty
> 168168  231     com.mysql.jdbc.Connection
> 36960   462
> com.mysql.jdbc.ConnectionProperties$MemorySizeConnectionProperty
> Heap traversal took 9.15 seconds.
> 
> The second number in each line is the object count. And it is increasing.
> 
> Greetings
> Achim

Achim,

Adding "profileSQL=true" to your URL causes the driver to log _every_
query to System.err, or another defined logger, so depending on how your
logging is setup, that could be filling a lot of memory due to how your
logging system buffers things.

"profileSQL" is not designed to be used in a production setting, is
there a reason you're running it in this manner?

	-Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEfuvJtvXNTca6JD8RAtFKAJ93QbniRUT1xOxqZBoSvEvlOlSmSQCgo5Y+
Ql2rupWQ/Fh9MVj+Ow08pBs=
=/7yE
-----END PGP SIGNATURE-----

-- 
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.