Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 97995 invoked from network); 15 Feb 2006 05:57:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Feb 2006 05:57:43 -0000 Received: (qmail 66146 invoked by uid 500); 15 Feb 2006 05:57:41 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 66115 invoked by uid 500); 15 Feb 2006 05:57:41 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 66106 invoked by uid 99); 15 Feb 2006 05:57:41 -0000 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=SPF_FAIL X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Feb 2006 21:57:39 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id EE9A9186 for ; Wed, 15 Feb 2006 06:57:17 +0100 (CET) Message-ID: <204956253.1139983037974.JavaMail.jira@ajax.apache.org> Date: Wed, 15 Feb 2006 06:57:17 +0100 (CET) From: "Satheesh Bandaram (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Closed: (DERBY-756) OutOfMemory Error on continous execution of select statement using COUNT() and DISTINCT on same connection In-Reply-To: <669631990.1134491326008.JavaMail.jira@ajax.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DERBY-756?page=all ] Satheesh Bandaram closed DERBY-756: ----------------------------------- > OutOfMemory Error on continous execution of select statement using COUNT() and DISTINCT on same connection > ---------------------------------------------------------------------------------------------------------- > > Key: DERBY-756 > URL: http://issues.apache.org/jira/browse/DERBY-756 > Project: Derby > Type: Bug > Components: Demos/Scripts, JDBC, Network Client, Network Server, SQL > Versions: 10.0.2.1, 10.1.2.1 > Environment: Windows XP, Java 1.5.0_05, Derby network server 10.0.2.1, 10.1.2.1, Derby heapsize 128m, IBM Universal JDBC driver > Reporter: Bill Chen > Assignee: Manish Khettry > Priority: Critical > Fix For: 10.2.0.0 > Attachments: mem_leak.diff > > The OutOfMemory is thrown when I continously execute a sql statement on an openned JDBC connection. A PreparedStatement and ResultSet is created on the connection everytime and close after each execution. I suspect that the bug is related to function COUNT() with keyword DISTINCT. For example, "select count(distinct ID) from TEST where FLAG <> 2". It will be fine if DISTINCT is not used, or select count(*) is used. > The exception like "Exception in thread "DRDAConnThread_2" java.lang.OutOfMemoryError: Java heap space" could be thrown on Derby side, or sometimes on client side. > Please find the test code and schema I used for testing: > create table: > CREATE TABLE Test > ( > ID BIGINT NOT NULL, > NAME VARCHAR(512) NOT NULL, > FLAG int, > CONSTRAINT PK_ID PRIMARY KEY (ID) > ); > insert data: > insert into TEST values (0, 'name0', 0); > insert into TEST values (1, 'name1', 1); > insert into TEST values (2, 'name2', 2); > Java client: > import java.sql.Connection; > import java.sql.PreparedStatement; > import java.sql.ResultSet; > import java.sql.DriverManager; > import java.sql.SQLException; > public class DerbyTest > { > static public void main(String args[]) throws Exception > { > Class.forName("com.ibm.db2.jcc.DB2Driver"); > Connection conn = null; > try > { > conn = DriverManager.getConnection("jdbc:derby:net://localhost:1527/testDB", "admin", "admin"); > for (int i = 0; i < 10000000; i++) > { > System.out.println("Query "+i); > String sql = "select count(distinct ID) from TEST where FLAG <> 2"; > PreparedStatement pStmt = null; > ResultSet rs = null; > try > { > pStmt = conn.prepareStatement(sql); > rs = pStmt.executeQuery(); > if (rs.next()) > { > rs.getInt(1); > } > } > catch (SQLException e) > { > e.printStackTrace(); > } > finally > { > if (rs != null) > rs.close(); > if (pStmt != null) > pStmt.close(); > } > } > } > finally > { > if (conn != null) > conn.close(); > } > } > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira