iOS - i receive memory warnings but have no idea why

Deadly 提交于 2019-12-04 17:17:39

问题


I am developing for the iOS and checking my app with IPhone and IPad.

I receive many memory warnings (didReceiveMemoryWarning is called) but have no idea why. My app is using ~35MB in the peak points, and 4-5 MB when it the lowest point.

I tried to find leaks using 'instruments' but could not find any critical issues.

Is there a good way to find out why the system sends memory warnings?


回答1:


Memory warning is to be expected in an iOS app. It doesn't have to be because of your app. Other apps are still in memory even if the apps are suspended. The OS will do memory management by sending memory warning and kill apps when necessary. As long as you're using reasonable amount of memory (with little to no memory leak) and handle didReceiveMemoryWarning properly, you'll be fine.

Also, when your app is in suspended mode, if your app is using little memory footprint, your app will more likely to survive killing process. As app with larger memory footprint will be terminated first.




回答2:


I also found that "Product -> Analyze" (Shift+Command+B) can help you sort out some code issues before you start using Leaks. With the introduction of ARC this became less useful though.



来源:https://stackoverflow.com/questions/9046595/ios-i-receive-memory-warnings-but-have-no-idea-why

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