pushtorefresh / storio

Reactive API for SQLiteDatabase and ContentResolver.
Apache License 2.0
2.55k stars 182 forks source link

StorIOException #778

Closed MerlinYu closed 7 years ago

MerlinYu commented 7 years ago

om.pushtorefresh.storio.StorIOException: android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. at com.pushtorefresh.storio.sqlite.operations.put.PreparedPutCollectionOfObjects.executeAsBlocking(SourceFile:148) at com.imaygou.android.data.MomosoDbManager.a(SourceFile:174) at com.imaygou.android.brand.BrandService.c(SourceFile:135) at com.imaygou.android.brand.BrandService.onHandleIntent(SourceFile:66) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:179) at android.os.HandlerThread.run(HandlerThread.java:61) Caused by: android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. at android.database.CursorWindow.(CursorWindow.java:108) at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138) at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132) at com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver.performPut(SourceFile:74) at com.pushtorefresh.storio.sqlite.operations.put.PreparedPutCollectionOfObjects.executeAsBlocking(SourceFile:112) ... 7 more

nikitin-da commented 7 years ago

Hi, @MerlinYu ! #779 contains almost the same log so I move it here. android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. at android.database.CursorWindow.(CursorWindow.java:108) at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138) at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132) at com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver.performPut(SourceFile:74) at com.pushtorefresh.storio.sqlite.operations.put.PreparedPutCollectionOfObjects.executeAsBlocking(SourceFile:112) at com.imaygou.android.data.MomosoDbManager.a(SourceFile:174) at com.imaygou.android.brand.BrandService.c(SourceFile:135) at com.imaygou.android.brand.BrandService.onHandleIntent(SourceFile:66) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:179) at android.os.HandlerThread.run(HandlerThread.java:61)

nikitin-da commented 7 years ago

It seems the problem is that cursors were not closed after usage. Particular places were not the cause since cursor is handled correctly: numberOfResults() and put(). Do you use storIoSqlite.get().cursor()? For this case you should close cursor manually after usage.

Also StrictMode can help to identify such places:

if (BuildConfig.DEBUG) {     
   StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
      .detectLeakedSqlLiteObjects()
      .detectLeakedClosableObjects()
      .penaltyLog()
      .penaltyDeath()
      .build());
}
artem-zinnatullin commented 7 years ago

Looks like this issue can be closed, feel free to comment!