“打开的文件太多”错误
在我的应用程序中,表单提交有一个插入操作。大多数情况下插入操作都是成功的。有时插入操作没有发生,然后它给出java.lang.RuntimeException
。这是 logcat 详细信息:
03-28 10:52:09.260: ERROR/IMemory(1501): cannot dup fd=1023, size=1048576, err=0 (Too many open files)
03-28 10:52:09.260: ERROR/IMemory(1501): cannot map BpMemoryHeap (binder=0x5919b0), size=1048576, fd=-1 (Bad file number)
03-28 10:52:09.260: ERROR/JavaBinder(1501): *** Uncaught remote exception! (Exceptions are not yet supported across processes.)
03-28 10:52:09.260: ERROR/JavaBinder(1501): java.lang.RuntimeException: No memory in memObj
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.database.CursorWindow.native_init(Native Method)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.database.CursorWindow.<init>(CursorWindow.java:518)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.database.CursorWindow.<init>(CursorWindow.java:27)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:493)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:496)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:96)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.os.Binder.execTransact(Binder.java:287)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at dalvik.system.NativeStart.run(Native Method)
我的代码可能有什么问题?
In my app, there is an insert operation on a form submission. Most of the cases the insert operation is successful. Sometimes the insertion operation is not happening and then , it is giving java.lang.RuntimeException
. Here is the logcat details:
03-28 10:52:09.260: ERROR/IMemory(1501): cannot dup fd=1023, size=1048576, err=0 (Too many open files)
03-28 10:52:09.260: ERROR/IMemory(1501): cannot map BpMemoryHeap (binder=0x5919b0), size=1048576, fd=-1 (Bad file number)
03-28 10:52:09.260: ERROR/JavaBinder(1501): *** Uncaught remote exception! (Exceptions are not yet supported across processes.)
03-28 10:52:09.260: ERROR/JavaBinder(1501): java.lang.RuntimeException: No memory in memObj
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.database.CursorWindow.native_init(Native Method)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.database.CursorWindow.<init>(CursorWindow.java:518)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.database.CursorWindow.<init>(CursorWindow.java:27)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:493)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:496)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:96)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at android.os.Binder.execTransact(Binder.java:287)
03-28 10:52:09.260: ERROR/JavaBinder(1501): at dalvik.system.NativeStart.run(Native Method)
What may be the problem in my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很多时候(正如 trjanfoe 所建议的)这些问题是因为游标仍然打开。我发现可以通过使用 try/finally 代码块来消除大多数问题。
这可以确保无论发生什么情况,游标都将始终关闭。
Very often (as trjanfoe suggested) these sorts of problems are because Cursors are still open. I've found that I can eliminate most of the problems by use try/finally codeblocks.
This ensures that the cursor will ALWAYS be closed, no matter what happens.