Issue Details (XML | Word | Printable)

Key: DERBY-557
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Knut Anders Hatlen
Reporter: Knut Anders Hatlen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Client driver gets OutOfMemoryError when re-executing statement without closing ResultSet

Created: 09/Sep/05 12:31 AM   Updated: 15/Feb/06 10:11 PM
Return to search
Component/s: Network Client
Affects Version/s: 10.1.1.0, 10.1.2.1, 10.2.1.6
Fix Version/s: 10.1.2.1, 10.2.1.6

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works DERBY-557-regression-test-v2.diff 2006-02-12 09:11 AM Knut Anders Hatlen 3 kB
File Licensed for inclusion in ASF works DERBY-557-regression-test-v3.diff 2006-02-15 06:49 PM Knut Anders Hatlen 3 kB
Text File Licensed for inclusion in ASF works DERBY-557-regression-test.diff 2006-02-12 07:47 AM Knut Anders Hatlen 3 kB
Text File Licensed for inclusion in ASF works DERBY-557-regression-test.stat 2006-02-12 07:47 AM Knut Anders Hatlen 0.3 kB
File Licensed for inclusion in ASF works DERBY-557.diff 2005-09-12 06:44 PM Knut Anders Hatlen 4 kB
Text File Licensed for inclusion in ASF works DERBY-557.stat 2005-09-12 06:44 PM Knut Anders Hatlen 0.2 kB
Text File Licensed for inclusion in ASF works derbyall_report.txt 2005-09-12 06:44 PM Knut Anders Hatlen 16 kB

Resolution Date: 15/Feb/06 09:50 PM


 Description  « Hide
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

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Knut Anders Hatlen made changes - 09/Sep/05 10:49 PM
Field Original Value New Value
Assignee Knut Anders Hatlen [ knutanders ]
Knut Anders Hatlen made changes - 12/Sep/05 06:44 PM
Attachment DERBY-557.diff [ 12312832 ]
Attachment derbyall_report.txt [ 12312834 ]
Attachment DERBY-557.stat [ 12312833 ]
Knut Anders Hatlen made changes - 12/Sep/05 06:45 PM
Status Open [ 1 ] In Progress [ 3 ]
Knut Anders Hatlen made changes - 07/Oct/05 03:59 PM
Resolution Fixed [ 1 ]
Fix Version/s 10.1.1.2 [ 12310353 ]
Status In Progress [ 3 ] Closed [ 6 ]
Knut Anders Hatlen made changes - 12/Feb/06 07:37 AM
Status Closed [ 6 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Knut Anders Hatlen made changes - 12/Feb/06 07:37 AM
Status Reopened [ 4 ] In Progress [ 3 ]
Knut Anders Hatlen made changes - 12/Feb/06 07:47 AM
Attachment DERBY-557-regression-test.stat [ 12322880 ]
Attachment DERBY-557-regression-test.diff [ 12322879 ]
Knut Anders Hatlen made changes - 12/Feb/06 09:11 AM
Attachment DERBY-557-regression-test-v2.diff [ 12322882 ]
Knut Anders Hatlen made changes - 15/Feb/06 06:49 PM
Attachment DERBY-557-regression-test-v3.diff [ 12322988 ]
Bernt M. Johnsen made changes - 15/Feb/06 09:50 PM
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Knut Anders Hatlen made changes - 15/Feb/06 10:11 PM
Status Resolved [ 5 ] Closed [ 6 ]