db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kathey Marsden <kmarsdende...@sbcglobal.net>
Subject Re: Iterating through large result set in network mode causes OutOfMemoryException
Date Sat, 09 Feb 2008 00:19:19 GMT
Briggs wrote:
> Thank you so much.  I guess I should have mentioned I was using jdk 6.
>   
With Sun jdk 1.6 I was able to reproduce the OutOfMemory error and 
Øystein was right;  it does look like DERBY-3354.  You were not seeing 
it with embedded because you never made  a getBlob() or getObject() call 
which is what triggers the bug. For Network Server that call happens 
under the covers.

There are a couple of workarounds that I can think of.
1) commit every 1000 rows or so.
     for(int i = 0; rs.next(); i++) {
            System.out.println("Read: " + i + " records.");
        if (i % 1000 == 0)
        conn.commit();
        }

2) do a getBlob and a free. This will work for network server but not 
embedded where it would still leak if you do a getBlob().
       for(int i = 0; rs.next(); i++) {
            System.out.println("Read: " + i + " records.");
        Blob b = rs.getBlob(1);
        b.free();
        }

HTH

Kathey





Mime
View raw message