memory – Android: Cursor Window is full-ThrowExceptions

Exception or error:

W/CursorWindow(15677): Window is full: requested allocation 2195889
bytes, free space 2096720 bytes, window size 2097152 bytes

I know there is app memory avaliable:

D/dalvikvm(15677): GC_FOR_ALLOC freed 9K, 30% free 17050K/24291K, paused 45ms

So its purely to do with the cursor size window, when Reading blob into byte[].

Im using the built in method to read blobs from a cursor.

        c = rdb.query("Photos", new String[]{"photo"}, "id = ?", new String[]{""+photoID}, null, null, null);
            byte[] tArray = c.getBlob(c.getColumnIndex("photo")); // THIS LINE ERRORS
    }catch(Exception e)

    return tArray;

Is there a way around this? The window size seems to be limited to 2097152 bytes.

How to solve:

It seems that the best way around this is to store the Photo on the SDCard, and save the URI in the DB.

While I wanted to avoid this, it’s not too bad, and is much more stable.

Leave a Reply

Your email address will not be published. Required fields are marked *