EXCEPTION: Too many open files (MonoTouch)

核能气质少年 提交于 2020-01-17 04:02:30

问题


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?


回答1:


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).



来源:https://stackoverflow.com/questions/15886034/exception-too-many-open-files-monotouch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!