Too many open files iOS

后端 未结 2 547
一生所求
一生所求 2021-01-16 09:31

i am new on ios programming, when my app is running , i am taking these errors. I am loading 950+ images in my app and i am using ARC.

ImageIO: CGImag

相关标签:
2条回答
  • 2021-01-16 09:43

    As far as I can see your code looks fine, and running in the simulator (where plenty of memory) this should be working. A few suggestions:

    1) use dataWithContentsOfFile:options:error: instead of dataWithContentsOfFile:, use the NSDataReadingUncached option (to reduce memory pressure on the system), and test the return value - if nil log the error and update your question.

    2) You can always dump the data image in a NSCache object, and if the system needs memory it will release cache items, and you'll have to re-read the image from the file system. You can use this technique even if you only pull a few images at a time.

    3) You can use UIImage imageWithContentsOfFile: instead of getting the data then creating the image. In this case put the UIImage itself in the cache, with a key of its name.

    0 讨论(0)
  • 2021-01-16 09:58

    From X-Code 10 Apple is not removing all NSCache instances dynamically as it done before. So as developer we need to Quit the simulator app and run the build your build be succeeded.

    0 讨论(0)
提交回复
热议问题