Proper use of ResultSetHandle and related memory leaks

View: New views
1 Messages — Rating Filter:   Alert me  

Proper use of ResultSetHandle and related memory leaks

by Lucas Madar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I have a pl/java routine that does some complex calculations based on database information, inserts it into another database table, and then essentially does a select on itself to return a resultSet:

    public ResultSet getResultSet() throws SQLException {
        if(resid != null) {
            statement = DriverManager.getConnection("jdbc:default:connection").createStatement();
            return statement.executeQuery("SELECT * FROM tblResult WHERE ResultID = '" + resid + "'");
        }
        return null;
    }

(resid is a class member variable, a UUID, and everything works fine).

However, executing this nearly 1,000 times in an open session leads to the postgres instance growing to nearly 1gb in memory usage. Clearly, there is a memory leak somewhere, but I would think that the ResultSet and its open connections would be gc'd once the class instance was no longer used.

So, I recoded the above to use a CachedResultSet, closed the connection and statement, and the memory leak still persists. Is there a proper way to use this that I'm not envisioning? Or have I run into a bug?

Thanks,
Lucas

_______________________________________________
Pljava-dev mailing list
Pljava-dev@...
http://pgfoundry.org/mailman/listinfo/pljava-dev