You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Bryan Pendleton (JIRA)" <de...@db.apache.org> on 2006/02/12 00:40:28 UTC

[jira] Commented: (DERBY-557) Client driver gets OutOfMemoryError when re-executing statement without closing ResultSet

    [ http://issues.apache.org/jira/browse/DERBY-557?page=comments#action_12366046 ] 

Bryan Pendleton commented on DERBY-557:
---------------------------------------

This change looks good to me. The patch applies cleanly to the current trunk. I read through the test code and thought it was fine. With your patch applied, I ran

java -Dframework=DerbyNetClient  -Dverbose=true org.apache.derbyTesting.functionTests.harness.RunTest jdbcapi/derbyStress.java

and got the expected results (test passed, with the new print statement appearing in the output as expected).


> Client driver gets OutOfMemoryError when re-executing statement without closing ResultSet
> -----------------------------------------------------------------------------------------
>
>          Key: DERBY-557
>          URL: http://issues.apache.org/jira/browse/DERBY-557
>      Project: Derby
>         Type: Bug
>   Components: Network Client
>     Versions: 10.1.1.0, 10.1.2.0, 10.2.0.0
>     Reporter: Knut Anders Hatlen
>     Assignee: Knut Anders Hatlen
>     Priority: Minor
>      Fix For: 10.1.2.0, 10.2.0.0, 10.1.1.2
>  Attachments: DERBY-557-regression-test.diff, DERBY-557-regression-test.stat, DERBY-557.diff, DERBY-557.stat, derbyall_report.txt
>
> When re-executing a statement without closing the old ResultSet, some of the old ResultSet's resources are not released, and the network client will eventually get an OutOfMemoryError.
> Example:
> 	Connection c = DriverManager.getConnection("jdbc:derby://localhost/mydb");
> 	PreparedStatement ps = c.prepareStatement("select * from sys.systables");
> 	while (true) {
> 		ResultSet rs = ps.executeQuery();
> 	}
> This code will run for some time and then throw an OutOfMemoryError. Same thing happens with Statement instead of PreparedStatement. If rs.close() is added in the loop, the code works. Explicitly closing the ResultSet should not be necessary according to this quote from the JDBC 3.0 spec:
>   For Select statements, the statement is complete when the associated result set is closed. The result set is closed as soon as one of the following occurs:
>      - all of the rows have been retrieved
>      - the associated Statement object is re-executed
>      - another Statement object is executed on the same connection

-- 
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


Re: [jira] Commented: (DERBY-557) Client driver gets OutOfMemoryError when re-executing statement without closing ResultSet

Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
"Bryan Pendleton (JIRA)" <de...@db.apache.org> writes:

> Bryan Pendleton commented on DERBY-557:
> ---------------------------------------
>
> This change looks good to me. The patch applies cleanly to the
> current trunk. I read through the test code and thought it was
> fine. With your patch applied, I ran
>
> java -Dframework=DerbyNetClient -Dverbose=true
> org.apache.derbyTesting.functionTests.harness.RunTest
> jdbcapi/derbyStress.java
>
> and got the expected results (test passed, with the new print
> statement appearing in the output as expected).

Thanks for testing the patch, Bryan. I just realized I forgot to put
conn.close() into the test method. Probably not important since it's
just a regression test, but I'll upload a new patch anyway.

-- 
Knut Anders