CursorWindow can not be created due to cursor [memory] leak

來源:互聯網
上載者:User

記錄了Android系統上由於cursor泄露導致記憶體耗盡(error -12)導致的CursorWindow不能再建立的Issue。

[Symptom]

08-30 20:27:36.751 E/CursorWindow(  760): Could not allocate CursorWindow '/data/data/com.android.providers.media/databases/external.db' of size 2097152 due to error -12.
08-30 20:27:36.771 E/JavaBinder(  760): *** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
08-30 20:27:36.771 E/JavaBinder(  760): android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=781 (# cursors opened by pid 3105=781)
08-30 20:27:36.771 E/JavaBinder(  760):  at android.database.CursorWindow.<init>(CursorWindow.java:104)
08-30 20:27:36.771 E/JavaBinder(  760):  at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
08-30 20:27:36.771 E/JavaBinder(  760):  at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:162)
08-30 20:27:36.771 E/JavaBinder(  760):  at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156)
08-30 20:27:36.771 E/JavaBinder(  760):  at android.database.CursorToBulkCursorAdaptor.count(CursorToBulkCursorAdaptor.java:184)
08-30 20:27:36.771 E/JavaBinder(  760):  at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:117)
08-30 20:27:36.771 E/JavaBinder(  760):  at android.os.Binder.execTransact(Binder.java:338)
08-30 20:27:36.771 E/JavaBinder(  760):  at dalvik.system.NativeStart.run(Native Method)

[Analysis]

logcat中有很明顯的下列輸出

Could not allocate CursorWindow '/data/data/com.android.providers.media/databases/external.db' of size 2097152due to error -12,

主要是due to error -12, ENOMEM,除非是其它原因記憶體耗盡,否則一般情況下是cursor泄露;注意errno是-12,如果是-24,EMFILE,則表示是進程內檔案描述符耗盡,則未必是cursor泄露的原因。

繼續從logcat中向前找,會發現大量的下列輸出,

08-30 20:27:24.909 D/dalvikvm( 3105): GC_EXPLICIT freed 1686K, 26% free 15810K/21315K, paused 8ms+16ms
08-30 20:27:24.919 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:24.929 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:24.949 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:24.949 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:24.969 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:24.989 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:24.989 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:24.989 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:24.999 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:24.999 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:24.999 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.009 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.009 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.009 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.019 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.019 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.019 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.019 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.029 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.029 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.029 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.039 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.039 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.039 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.039 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.049 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.049 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.049 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.049 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.049 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.049 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.059 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.059 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.059 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.059 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.059 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.059 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.069 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.069 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.069 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.069 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.069 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.069 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.069 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.079 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.079 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.079 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.079 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.079 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:27:25.079 W/CursorWrapperInner( 3105): Cursor finalized without prior close()

08-30 20:26:57.179 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.189 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.209 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.229 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.249 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.259 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.269 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.279 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.299 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.299 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.299 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.309 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.309 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.309 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.309 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.309 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.319 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.319 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.319 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.319 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.319 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.329 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.339 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.339 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.339 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.349 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.349 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.349 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.359 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.359 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.369 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.369 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.369 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.369 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.369 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.379 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.379 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.389 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.389 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.389 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.389 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.399 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.399 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.399 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.399 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.409 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.409 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.409 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.409 W/CursorWrapperInner( 3105): Cursor finalized without prior close()
08-30 20:26:57.419 W/CursorWrapperInner( 3105): Cursor finalized without prior close()

說明有很明顯的cursor leak。

解決辦法是找到使用cursor的地方,在使用完畢後cursor.close()即可。

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.