Could not allocate CursorWindow size due to error -12 错误解决方法


程序出现下面的错误:

08-30 20:27:36.751 E/CursorWindow(u 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(u 760): *** Uncaught remote exception!u (Exceptions are not yet supported across processes.)
08-30 20:27:36.771 E/JavaBinder(u 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(u 760):u at android.database.CursorWindow.<init>(CursorWindow.java:104)
08-30 20:27:36.771 E/JavaBinder(u 760):u at 
android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)08-30 20:27:36.771 E/JavaBinder(u 760):u at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:162)
08-30 20:27:36.771 E/JavaBinder(u 760):u at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156)
08-30 20:27:36.771 E/JavaBinder(u 760):u at android.database.CursorToBulkCursorAdaptor.count(CursorToBulkCursorAdaptor.java:184)
08-30 20:27:36.771 E/JavaBinder(u 760):u at android.content.ContentProviderNative.onTransact


主要是due to error -12, ENOMEM,除非是其它原因内存耗尽,否则一般情况下是cursor泄露;注意errno是-12,如果是-24,EMFILE,则表示是进程内文件描述符耗尽,则未必是cursor泄露的原因。


说明有很明显的cursor leak。
解决办法是找到使用cursor的地方,在使用完毕后cursor.close()即可。

你可能感兴趣的:(Could not allocate CursorWindow size due to error -12 错误解决方法)