Room database throwing CursorWindowAllocationException

Viewed 2682

Recently, I have started facing this exception. As far as I know, this exception gets thrown when the cursor is not closed after the transaction. However, Room database handles this in the DaoImpl code which is automatically generated. I'm not able to figure out the cause for this exception. Here is the stacktrace:

Fatal Exception: android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. 
   at android.database.CursorWindow.(CursorWindow.java:108)
   at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:226)
   at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:148)
   at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:142)
   at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219)
   at android.database.AbstractCursor.moveToNext(AbstractCursor.java:268)
   at android.arch.persistence.room.InvalidationTracker$1.checkUpdatedTable(InvalidationTracker.java:358)
   at android.arch.persistence.room.InvalidationTracker$1.run(InvalidationTracker.java:329)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
   at java.lang.Thread.run(Thread.java:764)

This is the query:

    @Query("select * from PhoneEvent where event_type=:type and 
    client_created_timestamp>=:startTimestamp and 
    client_created_timestamp<:endTimestamp")
    List<PhoneEvent> getAllPhoneEventsOfTypeAndBetween(String type, 
    long startTimestamp, long endTimestamp);

In the Dao_Impl, the exception is thrown at this line:

    final List<PhoneEvent> _result = new ArrayList<PhoneEvent>(_cursor.getCount());
0 Answers
Related