2

I use the room orm for saving data in my app. My app is running on android 5.1.1 and also I use androidx in the project. But after a while I got the below exception:

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)

But indeed Room manages Cursor automatically and there isn't any Cursor class in the whole project and furthermore, when this error happens there isn't any database-related transaction.

Masoud Badrmiran
  • 421
  • 2
  • 4
  • 11

1 Answers1

0

Finally, I found the answer. Be careful when you use WorkManager. It creates a database and updates work statuses and when this database grows it causes a crash. Here is detailed information.

WorkManager database: A local database that tracks all of the information and statuses of all of your work. This includes things like the current state of the work, the inputs and outputs to and from the work ,and any constraints on the work. This database is what enables WorkManager to guarantee your work will finish — if your user’s device restarts and work gets interrupted, all of the details of the work can be pulled from the database and the work can be restarted when the device boots up again.

Use pruneWork() in WorkManager when necessary

Masoud Badrmiran
  • 421
  • 2
  • 4
  • 11