Gene Cahill
Gene Cahill

Reputation: 124

CursorWindowAllocationException thrown in SyncAdapter

I occasionally get the following exception thrown in my SyncAdapter class. I think that I am closing all cursors correctly. Can there be any other explanation for why this exception is being thrown? Or am I definitely missing a cursor.close() somewhere?

Fatal Exception: android.database.CursorWindowAllocationException: Cursor window could not be created from binder.
       at android.database.CursorWindow.<init>(CursorWindow.java:150)
       at android.database.CursorWindow.<init>(CursorWindow.java:42)
       at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:698)
       at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:696)
       at android.database.BulkCursorDescriptor.readFromParcel(BulkCursorDescriptor.java:75)
       at android.database.BulkCursorDescriptor$1.createFromParcel(BulkCursorDescriptor.java:34)
       at android.database.BulkCursorDescriptor$1.createFromParcel(BulkCursorDescriptor.java:30)
       at android.content.ContentProviderProxy.query(ContentProviderNative.java:424)
       at android.content.ContentProviderClient.query(ContentProviderClient.java:161)
       at android.content.ContentProviderClient.query(ContentProviderClient.java:123)
       at com.forever.forever.Utils.sync.SyncAdapter.getNextItemInUploadQueue(SyncAdapter.java:799)
       at com.forever.forever.Utils.sync.SyncAdapter.proccessUploads(SyncAdapter.java:697)
       at com.forever.forever.Utils.sync.SyncAdapter.onPerformSync(SyncAdapter.java:199)
       at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:272)

Upvotes: 3

Views: 861

Answers (1)

Gene Cahill
Gene Cahill

Reputation: 124

I was able to find an additional closable leaks by adding the following snippet to my application onCreate():

    if(BuildConfig.DEBUG){
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                .detectLeakedSqlLiteObjects()
                .detectLeakedClosableObjects()
                .penaltyLog()
                .build());
    }

It logged a couple leaks that I was able to fix. This is an EXTREMELY helpful development tool.

Upvotes: 3

Related Questions