From: lucas at mcsnw.com (Lucas Madar) Date: Tue, 18 Aug 2009 10:27:53 -0700 Subject: [Pljava-dev] Proper use of ResultSetHandle and related memory leaks Message-ID: <4A8AE499.4040901@mcsnw.com> 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: