当应用程序在 ipad 中运行 10 分钟时,错误 = 24
我创建了一个应用程序,其中包含一个带有播放按钮的屏幕,用于播放音频文件。运行应用程序10分钟后出现问题;它在控制台中抛出此消息:
ImageIO:CGImageRead_mapData“打开” 失败的 '/用户/印第安人/图书馆/应用程序 支持/iPhone 模拟器/4.2/Applications/A511E515-6FEA-4D0D-A5C5-95740B14C858/VisualMath.app/pi_play.png' 错误= 24(打开的文件太多)
出现这些消息后,应用程序崩溃。任何人都知道为什么会出现这个问题以及如何解决它?
提前致谢。
I have created an application which consists of a screen with a play button to play an audio file. The problem occurs after running the application for 10 minutes; it throws this message in the console:
ImageIO: CGImageRead_mapData 'open'
failed
'/Users/indianic/Library/Application
Support/iPhone
Simulator/4.2/Applications/A511E515-6FEA-4D0D-A5C5-95740B14C858/VisualMath.app/pi_play.png'
error = 24 (Too many open files)
After these message the application crashes. Anyone knows why this problem occurs and how to fix it?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于我在同一个应用程序中使用数据库,因此有时我需要触发 sql 查询两次。因为我有两次火灾查询,所以数据库文件没有关闭,并且因此该文件在我的应用程序中打开了很多次。因此,应用程序崩溃并给出此错误。
因此,请始终检查数据库文件是否正在接近此类错误。
As I have work with database in the same application there is some point where i need to fire sql query twice. because I have fire query twice the database file is not getting close and because of that the file open many time in my application. and because of that the application is crash with giving this error.
so always check for the database file is getting close or not for this kind of the error.
我有一个非常相似的问题。对我来说,这与迭代次数(计数)而不是运行时间有关,我只是将问题追溯到我对 stop 方法的使用。看来 stop 方法在内存中留下了一些释放没有的资源(我猜测可能会恢复)。即使您在停止后调用释放(这就是我在audioPlayerDidFinishPlaying:成功:中所做的事情),如果我事先使用停止也是不够的。但是用释放代替停止,没有其他方法可以让我的问题消失。
I had a very similar problem. For me it had to do with the number of iterations (count) rather than time running, and I just tracked the problem down to my use of the stop method. It appears that the stop method leaves some resources in memory that release does not (I'm guessing for a possible resume). And even if you call release after stop, which is what I was doing in audioPlayerDidFinishPlaying:successfully: , it's wasn't enough if i'd used stop beforehand. But replacing stop with just release and nothing else made my problem go away.
看来您不断加载播放按钮的图像,这导致了异常。如果是这种情况,请尝试加载一次并在需要时更改按钮的图标。
如果您使用 NSFileHandle 在完成后关闭文件,或使用 [UIImage imageNamed:(NSString *)];
It looks like you keep loading images for the play button which causes the exception. If this is the case, try loading them once and change the icon of the button when needed.
If you are using NSFileHandle close the file when you are done with it, or use [UIImage imageNamed:(NSString *)];