ios - 什么级别的内存使用会触发 iOS 的内存警告?

标签 ios swift memory

我的应用可能会消耗数十 MB 的内存,在极少数情况下会达到 100 MB。我是否需要担心内存警告并实现 didReceiveMemoryWarning()?我需要多少时间来释放内存? (我需要将内存中的数据持久化到硬盘中。)

假设我以 iPhone 5 之后的设备为目标。

最佳答案

首先,这里是来自 Apple docs 的方法 didReceiveMemoryWarning讨论 .

反对

Your app never calls this method directly. Instead, this method is called when the system determines that the amount of available memory is low. You can override this method to release any additional memory used by your view controller. If you do, your implementation of this method must call the super implementation at some point.

据此reddit线程,即使你处理了这个事件,你的应用程序仍然可以被终止以给正在运行的应用程序空间。此外,通常会调用设备上所有应用的 didReceiveMemoryWarning,而不仅仅是您的。

我希望这个答案没问题,因为这似乎只是引用文档的评论:)

关于ios - 什么级别的内存使用会触发 iOS 的内存警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46923288/

相关文章:

ios - 从 Windows 移动到 mac 后,M1 上的 Flutter : GoogleMapsBase & Flutter. h 未发现错误

swift - 即使点击事件后,如何从 URL 加载部分 HTML?

ios - Swift - 如何访问第二个 uiwindow 上的 navBar 属性

ios - 如何以编程方式在 ScrollView 中嵌入堆栈 View

javascript - 如何使用嵌套 for 循环最好地优化函数

c++ - uint8_t vector 的内存地址

iOS App蓝牙无法连接外围设备

ios - Quickblox IOS sdk 是否支持以下所有选项?

ios - 使用 AIR 在 iOS 上流式传输 AAC+(在 FLV 内)

memory - 加速 Haskell 并发