2016-08-08 39 views
0

我偶爾會在SyncAdapter類中引發以下異常。我認爲,我正確關閉所有遊標。有沒有其他解釋爲什麼拋出這個異常?或者我肯定在某處丟失了cursor.close()?在SyncAdapter中引發CursorWindowAllocationException

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) 

回答

0

我能夠通過將下面的代碼片段,以我的應用程序的onCreate()找到一個額外的可封閉泄漏:

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

它記錄的一對夫婦的泄漏,我是能夠解決。這是一個極其有用的開發工具。