Note that there are some explanatory texts on larger screens.

plurals
  1. POSQLite Android Database Cursor window allocation of 2048 kb failed
    primarykey
    data
    text
    <p>I have a routine that runs different queries against an SQLite database many times per second. After a while I would get the error </p> <p><code>"android.database.CursorWindowAllocationException: - Cursor window allocation of 2048 kb failed. # Open Cursors = "</code> appear in LogCat.</p> <p>I had the app log memory usage, and indeed when usage reaches a certain limit the I get this error, implying it runs out. My intuition tells me that the database engine is creating a NEW buffer (CursorWindow) every time I run a query, and even though I mark the .close() the cursors, neither the garbage collector nor <code>SQLiteDatabase.releaseMemory()</code> are quick enough at freeing memory. I think the solution may lie in "forcing" the database to always write into the same buffer, and not create new ones, but I have been unable to find a way to do this. I have tried instantiating my own CursorWindow, and tried setting it to and SQLiteCursor to no avail.</p> <p>¿Any ideas?</p> <p>EDIT: re example code request from @GrahamBorland:</p> <pre><code>public static CursorWindow cursorWindow = new CursorWindow("cursorWindow"); public static SQLiteCursor sqlCursor; public static void getItemsVisibleArea(GeoPoint mapCenter, int latSpan, int lonSpan) { query = "SELECT * FROM Items"; //would be more complex in real code sqlCursor = (SQLiteCursor)db.rawQuery(query, null); sqlCursor.setWindow(cursorWindow); } </code></pre> <p>Ideally I would like to be able to <code>.setWindow()</code> before giving a new query, and have the data put into the same <code>CursorWindow</code> everytime I get new data. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload