例外:打开文件太多(MonoTouch) [英] EXCEPTION: Too many open files (MonoTouch)

查看:147
本文介绍了例外:打开文件太多(MonoTouch)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个MonoTouch应用程序,它可以下载超过1000个单独的PDF文件,并将它们打开为一个巨大的pdf文件。查看文档时没有问题,但如果我保持关闭/打开文档几次,它将抛出



EXCEPTION:打开文件太多
t系统在/ Developer / MonoTouch / Source / mono / mcs / class / corlib中的.IO.FileStream..ctor(System.String路径,FileMode模式,FileAccess访问,FileShare共享,Int32缓冲区大小,布尔匿名,FileOptions选项)[0x00275] System.IO/FileStream.cs:310
在System.IO.FileStream..ctor(System.String路径,FileMode模式)[0x00000] in:0



我已经使用MonoTouch几年了,没有任何这样的问题。这可能是一个新的Xamarin.iOS问题?



我也在论坛上看到他们使用 ulimit -a 修复了这个问题,但是如何我应用于iPad应用程序?



任何人?

解决方案

Xamarin.iOS本身的打开文件没有限制。但是,当操作系统(在这种情况下为iOS)报告太多文件被打开时,这个异常将被抛出。



检查你的设备日志(例如Xcode组织者),你应该看到iOS抱怨打开的文件数量。



处理文件时,甚至超过其他 IDisposable ,它是当您不再需要它们时,重要的是关闭它们。 IOW不要等待GC自动执行



此外,您还可以尝试使用乐器或
< a href =https://stackoverflow.com/q/4083608/220643>此可查看哪些文件是打开的 -
应该提示您谁打开它们。例如。他们可能不是全部(例如,如果您的应用程序中嵌入了许多字体)。


I'm writing an MonoTouch app that downloads over 1000 individual PDF files and open them as one giant pdf file. I have no problem viewing the document but if I keep close/open the document few times it will throw

EXCEPTION: Too many open files t System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00275] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/FileStream.cs:310 at System.IO.FileStream..ctor (System.String path, FileMode mode) [0x00000] in :0

I've been using MonoTouch for a couple years now and have not had any issues like this. Could this be a new Xamarin.iOS issue?

I also saw in the forum they fixed this issue by using ulimit -a but how do I apply that to an iPad app?

Anyone?

解决方案

There's no limit on open files inside Xamarin.iOS itself. However this exception will be thrown when the operating system (iOS in this case) reports too many files are open.

Check your device logs (e.g. Xcode organizer) and you should see iOS complains about the number of opened files.

When dealing with files, even more than other IDisposable, it's important to close them when you no longer require them. IOW do not wait for the GC to automagically do it.

Also you might want to try using Instruments or something like this to see which files are open - that should hint you about who opened them. E.g. they might not all be yours (e.g. if you embed many fonts inside your application).

这篇关于例外:打开文件太多(MonoTouch)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆