public inbox for [email protected]  
help / color / mirror / Atom feed
Subject: [Pljava-dev] Proper use of ResultSetHandle and related memory leaks
Date: Tue, 18 Aug 2009 10:27:53 -0700
Message-ID: <[email protected]> (raw)

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://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20090818/9a44483e/attachment.html;




reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Subject: Re: [Pljava-dev] Proper use of ResultSetHandle and related memory leaks
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox