Well, thanks to Lamda probe and then to jmap, I have found my memory leak. Here are the gory details in case anyone is interested. It's not really a Tomcat issue, but rather the boundary between Tomcat and MySQL:

I have a memory leak in my application, and jmap shows me that all my objects of type 'com.mysql.jdbc.Field' are not being released.

In my code I was calling resultSet.close(), but not statement.close().

Doing my homework, I found the forum postings about this and so corrected my code to include statement.close() as well as resultSet.close() after my database operations.

The problem is, even though I verified (debug statements) that the call is being made, the memory is STILL not being released. If I run the same large query 3 times in a row, my memory use triples. Even if I log off the session (my application) and invalidate the session, the memory is still locked up and cannot be freed by the JVM.

My application is java servlets, using Java 1.6.0_06-b02, Tomcat 6.0.15 with mysql-connector-java-5.1.6-bin.jar and Mysql 5.0.51b.

So what am I missing? I was sure that adding the code to close my statements would fix the problem.

UPDATE:

OK. In a way, I've fixed the problem. I checked my source code, and I'm now issuing the correct close() statements as required, so the memory leak is a puzzle.

BUT - I went back through past versions of the jdbc connector because *** this application used to work without any problems ***. Here's what I found. (GOOD means no memory leaks at all - even under extended testing; BAD means memory leaks immediately).

GOOD:

mysql.jar (221 kb, 10/7/2003)
mysql-connector-java-3.0.16-ga-bin.jar (231 kb, 11/16/2004)
mysql-connector-java-3.0.17-ga-bin.jar  (241 kb, 6/22/2005)

BAD (memory leak):

mysql-connector-java-3.1.10-bin.jar (409 kb, 6/23/2005)
mysql-connector-java-3.1.14-bin.jar (449 kb, 10/18/2006)
... (other versions)
mysql-connector-java-5.1.6-bin.jar (687 KB, 3/5/2008)

So - does anyone know what the major change was between 3.0.17 and 3.1.10 that would have such a dramatic effect?

Again, I realize this is not strictly a Tomcat problem (tomcat version is pretty much irrelevant to the problem), but many using Tomcat also use MySQL, so it's still "of interest".

Cheers,

-Richard

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to