Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
545 views
in Technique[技术] by (71.8m points)

memory - Android: Cursor Window is full

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.

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

    return tArray;

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...