Chris,


| If I close the resultset AND the statement, then the connector
| should release all the objects created by those two. The connection is,
| after all, just a pipe between the database and the java code. The
| connector should not (IMO) be hanging on to statement or resultset
| objects just because the connection is still in existance.

I completely agree. Two things that I can think of that might be causing
problems with the Connector itself:

1. ResultSetMetadata -- use of the metadata methods can cause additional
queries to be executed, which means more ResultSet objects, Fields, etc.
I didn't see any use of this in your sample code, so I suspect this is
not the issue.

OK. I tried closing RSMD's. You can't close them so I just made them null. It had no effect, but I'm not surprised since they come from the ResultSet and should (in theory) be destroyed when the ResultSet is closed (IMO).

HOWEVER - In messing with the code again ...

I FIXED THE PROBLEM!!!!!

Yep - totally fixed (tested and verified).

What I decided to do was to move the close statements (and nulling RSMD) into the FINALLY block - it seemed pointless to duplicate code. When you must have the close() statements in finally, why put them in the main code as well?

So I modified ALL my DBMS methods as follows (just showing the finally block):

        finally {
            try {
                if(resultSet != null) {
                    resultSet.close();
                    resultSet = null;
                }
                if(statement != null) {
                    statement.close();
                    statement = null;
                }
            }
            catch (Exception e) {
            }
        }

In doing this, I found several methods I missed earlier - they were update and delete methods that didn't use ResultSet so I had missed adding the statement.close().

So once I was done, EVERY METHOD in the DBMS class had appropriate closes on resultsets and statements (as appropriate) - all placed in the finally block.

Testing proved this to completely fix the memory leak.

Thanks again VERY much for all the advice and assistance!!!

:-)

Cheers,

-Richard

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to