X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6D94653039 for ; Fri, 12 Aug 2005 12:56:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17416-01 for ; Fri, 12 Aug 2005 15:56:16 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 0B1BE52CBD for ; Fri, 12 Aug 2005 12:56:14 -0300 (ADT) Received: (qmail 16099 invoked from network); 12 Aug 2005 15:56:14 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 12 Aug 2005 15:56:14 -0000 In-Reply-To: <52EF20B2E3209443BC37736D00C3C1380422A8B3@EXADV1.host.magwien.gv.at> References: <52EF20B2E3209443BC37736D00C3C1380422A8B3@EXADV1.host.magwien.gv.at> Mime-Version: 1.0 (Apple Message framework v733) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <1E469344-B19D-424E-A6DA-11B159347F1F@fastcrypt.com> Cc: Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: Memory leak in 8.0 JDBC driver? Date: Fri, 12 Aug 2005 11:56:12 -0400 To: Albe Laurenz X-Mailer: Apple Mail (2.733) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=[AWL=0.013] X-Spam-Level: X-Archive-Number: 200508/87 X-Sequence-Number: 13656 On 12-Aug-05, at 11:15 AM, Albe Laurenz wrote: > I think that I have found the memory leak, and it is indeed in the > JDBC > driver. > All code references in the following refer to the 8.0-312 JDBC Source. > > I have an org.postgresql.jdbc3.Jdbc3PreparedStatement containing > INSERT INTO PARENT (ID, NAME, NUMMER) VALUES (?, ?, ?) > I execute this statement thousands of times with different parameters. > After each execution I commit(). > Some of these statements fail due to a constraint violation, then I > rollback(). > > Whenever this statement is executed *and fails*, execution reaches > org.postgresql.core.v3.QueryExecutorImpl.processResults(), line 1280 > where an org.postgresql.util.PSQLWarning is retrieved with the > contents: > LOG: statement: INSERT INTO PARENT (ID, NAME, NUMMER) VALUES ($1, $2, > $3) > > The handler that handles the warning is the anonymous class in > org.postgresql.core.v3.QueryExecutorImpl.sendQueryPreamble(), line > 381. > > This in turn calls > org.postgresql.jdbc2.AbstractJdbc2Statement.StatementResultHandler.han > dl > eWarning(), line 191. > > This causes the SQLWarning to be appended at the end of the warning > chain of > the prepared statement, as you can see in > org.postgresql.jdbc2.AbstractJdbc2Statement.addWarning(), line 546. > > The problem is that the warning chain is never cleared. According > to the > documentation of java.sql.Statement.getWarnings(), > 'The warning chain is automatically cleared each time a statement is > (re)executed' > This obviously does not happen. > > Indeed, when searching the source of the JDBC driver, I cannot find a > single reference > to the clearWarnings() method, nor is > org.postgresql.jdbc2.AbstractJdbc2Statement.warnings > ever reset directly. > > The warnings chain grows endlessly and gobbles up the heap. > > I guess I should file a bug report for this, right? You just did, thanks Dave > > Yours, > Laurenz Albe > > ---------------------------(end of > broadcast)--------------------------- > TIP 2: Don't 'kill -9' the postmaster > >