Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 48623 invoked from network); 8 Aug 2008 00:14:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Aug 2008 00:14:19 -0000 Received: (qmail 70261 invoked by uid 500); 8 Aug 2008 00:14:06 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 70230 invoked by uid 500); 8 Aug 2008 00:14:06 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 70219 invoked by uid 99); 8 Aug 2008 00:14:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2008 17:14:06 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of huntrods@nucleus.com designates 66.18.251.14 as permitted sender) Received: from [66.18.251.14] (HELO MAIL.nucleus.com) (66.18.251.14) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Aug 2008 00:13:09 +0000 Received: from [10.1.1.99] (dsl-bc-66-18-215-138-bc.nucleus.com [66.18.215.138]) by MAIL.nucleus.com (Vircom SMTPRS 4.5.654.13) with ESMTP id for ; Thu, 7 Aug 2008 18:13:18 -0600 X-Modus-ReverseDNS: OK X-Modus-BlackList: 66.18.215.138=OK;huntrods@nucleus.com=OK X-Modus-RBL: 66.18.215.138=Excluded X-Modus-Trusted: 66.18.215.138=NO X-Modus-Audit: FALSE;0;0;0 Message-ID: <489B8FA1.3080504@nucleus.com> Date: Thu, 07 Aug 2008 17:13:21 -0700 From: "Richard S. Huntrods" User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: users@tomcat.apache.org Subject: Re: Would like to monitor memory use offline Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org