[ http://issues.apache.org/jira/browse/DERBY-210?page=comments#action_12363983 ]
Deepa Remesh commented on DERBY-210: ------------------------------------ Thanks Kathey, Bryan and Dan for your comments. As Bryan pointed out, the javadoc for Statement.close mentions "A Statement object is automatically closed when it is garbage collected". I did not see this mentioned in the JDBC spec though. However, I still think close() and finalize() must be different. close() methods can throw SQLExceptions. javadoc for finalize() says this "Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored." So I think we should just ensure that we can clean up all resources when finalize() gets run. Another reason which Dan pointed out is that the order of finalizer execution is not guaranteed. Dan, after reading through Section 10.1, I think we do not need to auto-commit when we close a statement. Kathey, I tried to force gc to repro this problem on other VMs. But I was not successful in creating another repro. The thing is that I am not able to repro this at all anymore, not even on jdk1.5. After I updated my local svn workspace and applied my original patch, I do not get this problem anymore. However, it consistently repoduces with jdk1.5 when running with the revision where the patch was committed (svn 369612). So I am doing changes on svn revision 369612 and running tests to verify this problem does not occur. Then I'll update to latest svn revision, do the same changes and run tests. I cannot think of any other way to verify this. > Network Server will leak prepared statements if not explicitly closed by the > user until the connection is closed > ---------------------------------------------------------------------------------------------------------------- > > Key: DERBY-210 > URL: http://issues.apache.org/jira/browse/DERBY-210 > Project: Derby > Type: Bug > Components: Network Client > Reporter: Kathey Marsden > Assignee: Deepa Remesh > Attachments: derby-210.diff, derby-210.status, derbyStress.java > > Network server will not garbage collect prepared statements that are not > explicitly closed by the user. So a loop like this will leak. > ... > PreparedStatement ps; > for (int i = 0 ; i < numPs; i++) > { > ps = conn.prepareStatement(selTabSql); > rs =ps.executeQuery(); > while (rs.next()) > { > rs.getString(1); > } > rs.close(); > // I'm a sloppy java programmer > //ps.close(); > } > > To reproduce run the attached program > java derbyStress > Both client and server will grow until the connection is closed. > > It is likely that the fix for this will have to be in the client. The client > does not send protocol to close the prepared statement, but rather reuses the > PKGNAMCSN on the PRPSQLSTT request once the prepared statement has been > closed. This is how the server knows to close the old statement and create a > new one. -- 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
