Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#94 Memory Leak with Mysql under low values of wait_timeout

open
nobody
None
5
2011-02-25
2011-02-25
Anuraag Godika
No

Hi,
c3p0 leaks memory when mysql global variable wait_timeout is set to a low value.
In this case, mysql server closes idle connections at its own end when wait_timeout expires. C3p0 detects an invalid connection but does not clean it up properly. The JDBC4Connection and its Properties stay resident in memory and are never Garbage Collected.

In order to reproduce the bug, I am attaching a very simple test case file.
Please use a mysql server where wait_timeout is set to 3 (seconds).
With JVM variables -Xmx16m and -Xms16m, the applications gets an OutOfMemory on my system within a couple of minutes, with c3p0 pooling.
With direct JDBC via Mysql Driver, it stays stable.

Version I used :
c3p0 - 0.9.1.2
Mysql connector/J - 5.1.15
JDK - 1.6 u 21

Discussion

  • Anuraag Godika
    Anuraag Godika
    2011-02-25

    File to reproduce the bug described.

     
    Attachments