Return-Path: Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 49495 invoked from network); 3 Sep 2003 20:05:51 -0000 Received: from unknown (HELO rj.sgi.com) (192.48.171.6) by daedalus.apache.org with SMTP; 3 Sep 2003 20:05:51 -0000 Received: from pinckneya.peachtree.sgi.com (pinckneya.peachtree.sgi.com [169.238.221.130]) by rj.sgi.com (8.12.9/8.12.9/linux-outbound_gateway-1.1) with SMTP id h83I7nOO004702 for <@external-mail-relay.sgi.com:tomcat-user@jakarta.apache.org>; Wed, 3 Sep 2003 11:07:49 -0700 Received: from dogwood.peachtree.sgi.com by pinckneya.peachtree.sgi.com via ESMTP (950413.SGI.8.6.12/930416.SGI) for <@pinckneya.peachtree.sgi.com:tomcat-user@jakarta.apache.org> id QAA08716; Wed, 3 Sep 2003 16:05:30 -0400 Received: from sgi.com (ptc-222-17-pc.peachtree.sgi.com [169.238.222.17]) by dogwood.peachtree.sgi.com (980427.SGI.8.8.8/980728.SGI.AUTOCF) via ESMTP id QAA03853 for ; Wed, 3 Sep 2003 16:05:29 -0400 (EDT) Message-ID: <3F564987.93CA02FC@sgi.com> Date: Wed, 03 Sep 2003 16:05:28 -0400 From: Jim Lynch Reply-To: jwl@sgi.com Organization: SGI X-Mailer: Mozilla 4.75 [en]C-CCK-MCD SGI (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Memory leaks? References: <3F561D40.16D499BD@sgi.com> <008901c37251$75a3c390$6401a8c0@plwkstn> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N OK, that's probably what's going on. I know I should close Statements and Connections and do normally but I'm fairly certain I've some out there dangling. I didn't know you had to close ResultSets, however. Glad to know that. Thanks, Jim. Paul wrote: > > Docs indicate that leaving a stmt or rs object open can cause memory leaks. > Found the following in the tomcat docs somewhere, i think: > > Here is an example of properly written code to use a db connection obtained > from a connection pool: > > Connection conn = null; > Statement stmt = null; // Or PreparedStatement if needed > ResultSet rs = null; > try { > conn = ... get connection from connection pool ... > stmt = conn.createStatement("select ..."); > rs = stmt.executeQuery(); > ... iterate through the result set ... > rs.close(); > rs = null; > stmt.close(); > stmt = null; > conn.close(); // Return to connection pool > conn = null; // Make sure we don't close it twice > } catch (SQLException e) { > ... deal with errors ... > } finally { > // Always make sure result sets and statements are closed, > // and the connection is returned to the pool > if (rs != null) { > try { rs.close(); } catch (SQLException e) { ; } > rs = null; > } > if (stmt != null) { > try { stmt.close(); } catch (SQLException e) { ; } > stmt = null; > } > if (conn != null) { > try { conn.close(); } catch (SQLException e) { ; } > conn = null; > } > } > > ----- Original Message ----- > From: "Jim Lynch" > To: "tomcat" > Sent: Wednesday, September 03, 2003 12:56 PM > Subject: Memory leaks? > > > I seemed to have read that java/tomcat isn't supposed to have memory > > leaks, but something seems to be running me out of memory and I don't > > know what. > > > > After a number of edit/undeploy/compile/deploy iterations I get the > > following: > > > > javax.servlet.ServletException: Servlet execution threw an exception > > at > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application > FilterChain.java:269) > > at > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh > ain.java:193) > > > > (Big snip) > > > > > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne > ction(Http11Protocol.java:392) > > at > > org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565) > > at > > > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav > a:619) > > at java.lang.Thread.run(Thread.java:536) > > > > root cause > > > > java.lang.OutOfMemoryError > > > > I'm running tomcat 4.1.24 on Linux with Apache 1.something. Java > > 1.4.1_02. > > > > So where do I start looking for the problem? If I forget to close > > Statements would that cause the problem? > > > > Thanks, > > Jim. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org