同步适配器中引发了CursorWindowAllocationException异常。

3

我在我的SyncAdapter类中偶尔会遇到以下异常。我认为我正确关闭了所有游标。除了游标未关闭之外,还有其他可能导致这种异常的原因吗?或者我确实漏掉了某个游标的关闭操作?

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个回答

3
我能够通过在我的应用程序onCreate()中添加以下代码片段来找到一个可关闭的额外泄漏:

我通过在我的应用程序onCreate()中添加以下代码片段,找到了一个可以关闭的额外泄漏:

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

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接