iOS - i receive memory warnings but have no idea w

2020-06-09 08:05发布

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?

2条回答
闹够了就滚
2楼-- · 2020-06-09 08:11

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.

查看更多
Rolldiameter
3楼-- · 2020-06-09 08:17

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.

查看更多
登录 后发表回答