Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 789971337A5D for ; Wed, 6 Apr 2011 08:02:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 93172-04 for ; Wed, 6 Apr 2011 11:02:36 +0000 (UTC) X-Greylist: delayed 00:09:51.264553 by SQLgrey-1.7.6 Received: from mail.mnc.ch (62-2-77-205.static.cablecom.ch [62.2.77.205]) by mail.postgresql.org (Postfix) with ESMTP id 24B311337999 for ; Wed, 6 Apr 2011 08:02:36 -0300 (ADT) Received: from localhost (mail2.mnc.ch [127.0.0.1]) by mail.mnc.ch (Postfix) with ESMTP id 512FD23051; Wed, 6 Apr 2011 10:52:43 +0000 (GMT) X-Virus-Scanned: amavisd-new at mnc.ch Received: from mail.mnc.ch ([127.0.0.1]) by localhost (mail2.mnc.ch [127.0.0.1]) (amavisd-new, port 10025) with LMTP id x6YCcUVMKRxQ; Wed, 6 Apr 2011 10:52:42 +0000 (GMT) Received: from meuh.localdomain (62-2-77-204.static.cablecom.ch [62.2.77.204]) by mail.mnc.ch (Postfix) with ESMTP id 0099B23050; Wed, 6 Apr 2011 10:52:41 +0000 (GMT) Received: by meuh.localdomain (Postfix, from userid 1000) id DF91C110279; Wed, 6 Apr 2011 12:52:41 +0200 (CEST) To: Pierre Le =?iso-8859-1?Q?Mou=EBllic?= Cc: pgsql-jdbc@postgresql.org Subject: Re: Memory leak ? References: <4D9C3E01.9030403@xgs-france.com> From: Guillaume Cottenceau X-Hashcash: 1:21:110406:pierre.lemouellic@xgs-france.com::j57E2O+kmln6N2G3:000000000000000000000000000002akG X-Hashcash: 1:21:110406:pgsql-jdbc@postgresql.org::5M/4umL01SrMfyBb:0000000000000000000000000000000000002+qf Date: Wed, 06 Apr 2011 12:52:41 +0200 In-Reply-To: <4D9C3E01.9030403@xgs-france.com> ("Pierre Le =?iso-8859-1?Q?Mou=EBllic=22's?= message of "Wed\, 06 Apr 2011 12\:18\:41 +0200") Message-ID: <87hbab6492.fsf@mnc.ch> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201104/34 X-Sequence-Number: 21760 Pierre Le Mouëllic writes: > With this code : > > public class TestJDBC { [...] > try { > sQLStatement.setInt(1, 2602); > rs = sQLStatement.executeQuery(); > sQLStatement.setInt(1, 2604); > rs = sQLStatement.executeQuery(); > sQLStatement.setInt(1, 2605); > rs = sQLStatement.executeQuery(); > } catch (SQLException e) { > } > finally{ > > try { > if(rs!=null) > rs.close(); e.g. you explicitely close only the last resultset of the three you produced (assuming no exception) > In eclipse Helios profiler, Jdbc3ResultSet live instances increase (and never > decrease). Same thing with Garbage collection is not predictable, closing resultsets (and statements) is strongly adviced if you want to release JDBC resources in a timely manner. I have never used this profiler but it would be interesting to know if any references are keeping these objects alive (then we could begin thinking of a leak), or if they are only not yet collected by the GC because it decided not to do it yet for any reason. Interestingly, the diff between: http://download.oracle.com/javase/1.4.2/docs/api/java/sql/Statement.html#close() and: http://download.oracle.com/javase/6/docs/api/java/sql/Statement.html#close() shows they've removed "Statement object is automatically closed when it is garbage collected." no idea why though. probably a more seasoned PG-JDBC dev/user would have? -- Guillaume Cottenceau