X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 997AC9DC99E for ; Wed, 11 Jan 2006 10:43:40 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90465-09 for ; Wed, 11 Jan 2006 10:43:44 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mosaic02.mosaic.de (mosaic02.mosaic.de [195.247.16.18]) by postgresql.org (Postfix) with ESMTP id D8D6F9DC98A for ; Wed, 11 Jan 2006 10:43:37 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mosaic02.mosaic.de (Postfix) with ESMTP id 14902778E1; Wed, 11 Jan 2006 15:45:02 +0100 (CET) Received: from mosaic02.mosaic.de ([127.0.0.1]) by localhost (mosaic02.mosaic-ag.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05178-20; Wed, 11 Jan 2006 15:45:01 +0100 (CET) Received: from mailproxy.mosaic.de (proxy01.mosaic.de [172.17.201.1]) by mosaic02.mosaic.de (Postfix) with ESMTP id EEE53778BA; Wed, 11 Jan 2006 15:45:00 +0100 (CET) Received: by mailproxy.mosaic.de (Postfix, from userid 10000) id A20B83A710; Wed, 11 Jan 2006 15:43:39 +0100 (CET) Received: from enterprise.mosaic-ag.com (enterprise.mosaic-ag.com [172.17.4.21]) by mailproxy.mosaic.de (Postfix) with ESMTP id 9394F3A70F; Wed, 11 Jan 2006 15:43:39 +0100 (CET) Received: from aupc287.mosaic-ag.com ([172.17.1.87]) by enterprise.mosaic-ag.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 11 Jan 2006 15:41:26 +0100 To: =?iso-8859-1?q?Kov=E1cs_P=E9ter?= Cc: pgsql-jdbc@postgresql.org Subject: Re: Memory leak or client side caching? References: <43C50E31.5040104@chemaxon.hu> From: Roland Walter Date: Wed, 11 Jan 2006 15:43:36 +0100 In-Reply-To: <43C50E31.5040104@chemaxon.hu> =?iso-8859-1?q?=28Kov=E1cs_P=E9ter's?= message of "Wed, 11 Jan 2006 14:54:57 +0100") Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, cygwin32) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-OriginalArrivalTime: 11 Jan 2006 14:41:26.0828 (UTC) FILETIME=[1A0C46C0:01C616BD] X-Virus-Scanned: mosaic-ag.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200601/50 X-Sequence-Number: 14501 Kov=E1cs P=E9ter writes: > Hi, > > Executing the following code results in an increase of 1GB in memory > usage by the process. > > String sql =3D "SELECT > cd_id,cd_fp1,cd_fp2,cd_fp3,cd_fp4,cd_fp5,cd_fp6,cd_fp7,cd_fp8,cd_fp9,cd_f= p10,cd_fp11,cd_fp12,cd_fp13,cd_fp14,cd_fp15,cd_fp16,cd_smiles > FROM editexample1"; > PreparedStatement ps =3D conn.prepareStatement(sql); > try { > ResultSet rs =3D ps.executeQuery(); > try { > while (rs.next()) { > int cdId =3D rs.getInt(1); > for (int i =3D 0; i < 16; i++) { > int fp =3D rs.getInt(i+2); > } > String cdSmiles =3D rs.getString(18); > } > } finally { > rs.close(); > } > } finally { > ps.close(); > } > > The result set contains 1 250 000 rows. > > I am not sure if this is a memory leak or the driver just caches the > result set on the client side. If this is the latter, is there a way > to turn off client side caching? If the former, how should I proceed > to find the problem? > If you do not use a cursor, the ResultSet tries to load all rows into the memory. Before executing the query you should set autocommit to false and set the fetchsize on the PreparedStatement to the maximal count of rows that are loaded into the memory: con.setAutoCommit(false); ps.setFetchSize(1000); --=20 Roland Walter mailto: rwa (at) mosaic-ag (dot) com MOSAIC SOFTWARE AG phone: +49 (0) 22 25 / 88 2-41 1 Am Pannacker 3 fax: +49 (0) 22 25 / 88 2-20 1 D-53340 Meckenheim http://www.mosaic-ag.com Die in dieser E-Mail enthaltenen Nachrichten und Anhaenge sind ausschliesslich fuer den bezeichneten Adressaten bestimmt. Sie koennen rechtlich geschuetzte, vertrauliche Informationen enthalten. Falls Sie nicht der bezeichnete Empfaenger oder zum Empfang dieser E-Mail nicht berechtigt sind, ist die Verwendung, Vervielfaeltigung oder Weitergabe von Nachrichten und Anhaengen untersagt. Falls Sie diese E-Mail irrtuemlich erhalten haben, informieren Sie bitte unverzueglich den Absender und vernichten Sie die E-Mail. This e-mail message and any attachment are intended exclusively for the named addressee. They may contain confidential information which may also be protected by professional secrecy. Unless you are the named addressee (or authorised to receive for the addressee) you may not copy or use this message or any attachment or disclose the contents to anyone else. If this e-mail was sent to you by mistake please notify the sender immediately and delete this e-mail.