ios - 新iPad : Low Memory Warnings Not Appearing?

标签 ios memory-management ipad-3

我一直在为 iPad 开发一个图形密集型应用程序。我已经能够在 iPad 2 上榨取相当多的性能,但新 iPad 的 @2x 图形在内存方面发挥了相当大的作用。使用 Instruments 中的 Activity Monitor,我可以看到我的应用程序的大小迅速增加到 300MB-400MB 范围内,但我没有收到任何内存不足的通知。我正在使用 UINavigationController 来管理我的 View ,因此进入堆栈会对内存产生累积影响,最终终止。我在 iPad 2 上没有遇到这个问题,我在 iPad 2 上收到了预期的内存不足通知。我的应用已编码为尽可能多地进行清理,并且在该设备上运行良好。

我看过很多类似的问题:

IOS app killed for Low Memory but no Memory Warning received
<强> iPhone app uses 150 MB memory and still no low memory warning!

这些建议似乎都没有帮助。

我已插入代码以强制发送低内存通知:

[[UIApplication sharedApplication] _performMemoryWarning];

这确实会导致非事件 View 按预期卸载并将内存消耗恢复正常。这使用私有(private) API 并且是 hack,因此出于实际原因不是解决方案。 如何让我的设备正确响应内存不足的情况并让我的应用知道它需要清理?

最佳答案

我联系了 Apple 支持来解决我的内存问题,并询问了 iPad 3 上的低内存警告:

-Because memory warnings are delivered on the main thread, your app will not receive memory warnings if it's blocking the main thread.

-Even if your app is not blocking the main thread, it is possible for memory usage to grow quickly enough that memory warnings are not delivered before your app is killed to free memory.

-Memory warnings trigger when the kernel transitions between various levels of memory pressure. Because of this, it is common for an app to receive a memory warning and then be killed quite some time later when memory is exhausted. The initial memory warning freed enough memory to keep the app alive, but not enough for the kernel to transition to a lower level of memory pressure.

Because of all this, memory warning should be treated as a useful data on the state of the hardware and a good guide on how much memory your app should use on a given device, but should not be relied on as a tool to prevent your app from being killed.

也许这有助于...

关于ios - 新iPad : Low Memory Warnings Not Appearing?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9753691/

相关文章:

ios - 如何为 NSURLRequest 设置 x-access-token?

c++ - 方法参数的内存错误(访问冲突)

c++ - 使用 itoa() 的最佳实践是什么

ios - 如何调试 Safari 6 (iOS) 连接错误?

ios - 在文件夹 swift iOS 中创建 Google 电子表格

ios - PFQueryTableViewController刷新数据

c++ - 释放堆上的内存。我应该和如何?

Safari - 网站在 iOS 6.0.1 而不是在 iOS 5.x 中崩溃

ios - 为什么视口(viewport)元常量设备宽度不为 ipad 3 返回 1536 像素而不是 768 像素?

ios - 绘制中 uibezierpath 上的阴影设置(矩形 :) removed when view is redrawn