iOS - 我收到内存警告,但不知道为什么 [英] iOS - i receive memory warnings but have no idea why

查看:121
本文介绍了iOS - 我收到内存警告,但不知道为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iOS开发并使用IPhone和IPad检查我的应用。

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

我收到许多内存警告(调用didReceiveMemoryWarning)但不明白为什么。
我的应用在峰值点使用~35MB,在最低点使用4-5 MB。

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?

推荐答案

在iOS应用中可以预期内存警告。它不一定是因为你的应用程序。即使应用程序被暂停,其他应用程序仍在内存中。操作系统将通过发送内存警告并在必要时终止应用程序来执行内存管理。只要您使用合理数量的内存(几乎没有内存泄漏)并正确处理didReceiveMemoryWarning,您就可以了。

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.

这篇关于iOS - 我收到内存警告,但不知道为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆