I have a routine that runs different queries on an SQLite database many times per second. After a while I get an error
"android.database.CursorWindowAllocationException: - Cursor window allocation of 2048 kb failed. # Open Cursors = " displayed in LogCat.
I had an application log memory usage, and indeed, when usage reaches a certain limit, I get this error, meaning that it ends. My intuition tells me that the database engine creates a new buffer (CursorWindow) every time I run the query, and although I mark .close () cursors, neither the garbage collector nor SQLiteDatabase.releaseMemory() frees up the memory fast enough, I think that the solution may be to “force” the database to always write to the same buffer, rather than creating new ones, but I could not find a way to do this. I tried to create an instance of my own CursorWindow and tried to configure it, and SQLiteCursor failed.
¿Any ideas?
EDIT: repeat the sample code request from @GrahamBorland:
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";
Ideally, I would like to be able to .setWindow() before giving a new request, and every time I get new data, the data is placed in the same CursorWindow .
android memory sqlite memory-leaks cursor
alex Jul 05 2018-12-12T00: 00Z
source share