0

I got two crush on firebase 1.Caused by android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. 2.Caused by android.database.CursorWindowAllocationException: Could not allocate CursorWindow '/data/user/0/com.myname.de/databases/bm_634255623.db' of size 2097152 due to error -12.

i know cursor leak,but i use jetpack room, i can't get cursor

room version:

 def room_version = "2.2.5"
    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"

please help me,thanks

why happen this crush?

zilin du
  • 1
  • 3
  • 1
    Does this answer your question? [Could not allocate CursorWindow](https://stackoverflow.com/questions/17495713/could-not-allocate-cursorwindow) – Ken Y-N Feb 15 '23 at 06:22
  • Note that since you haven't posted the calling code it's difficult to be sure, but you're probably creating but not freeing `Cursor`s within a loop somewhere. – Ken Y-N Feb 15 '23 at 06:24
  • i use jetpack room,i can't get Cursor – zilin du Feb 15 '23 at 06:32

1 Answers1

-1

This issue could happen because of memory allocation for Cursor. The idea is that the CursorWindows has maximum 2mb so for that query in order to get some consistent data.

@Dao
interface UserDao {
    @Transaction
    @Query("SELECT * FROM user")
    fun getAll(): List<User>
}

You should annotate your DAO methods with @Transaction to get rid of this error.