[Pljava-dev] Proper use of ResultSetHandle and related memory leaks

Lucas Madar lucas at mcsnw.com
Tue Aug 18 17:27:53 UTC 2009


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pgfoundry.org/pipermail/pljava-dev/attachments/20090818/9a44483e/attachment.html>


More information about the Pljava-dev mailing list