Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-557

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

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • 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
    • Component/s: Network Client
    • Labels:
      None

      Description

      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

        Attachments

        1. derbyall_report.txt
          16 kB
          Knut Anders Hatlen
        2. DERBY-557-regression-test-v3.diff
          3 kB
          Knut Anders Hatlen
        3. DERBY-557-regression-test-v2.diff
          3 kB
          Knut Anders Hatlen
        4. DERBY-557-regression-test.stat
          0.3 kB
          Knut Anders Hatlen
        5. DERBY-557-regression-test.diff
          3 kB
          Knut Anders Hatlen
        6. DERBY-557.stat
          0.2 kB
          Knut Anders Hatlen
        7. DERBY-557.diff
          4 kB
          Knut Anders Hatlen

          Activity

            People

            • Assignee:
              knutanders Knut Anders Hatlen
              Reporter:
              knutanders Knut Anders Hatlen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: