在SyncAdapter中抛出CursorWindowAllocationException

时间:2016-08-08 13:33:14

标签: android

我偶尔会在SyncAdapter类中抛出以下异常。我认为我正在关闭所有游标。是否有任何其他解释为什么抛出此异常?或者我绝对错过了某个地方的cursor.close()?

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)

1 个答案:

答案 0 :(得分:3)

通过将以下代码段添加到我的应用程序onCreate(),我能够找到其他可关闭的泄漏:

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

它记录了一些我能够解决的漏洞。这是一个非常有用的开发工具。