iphone - 是否可以确定内存警告的级别?

标签 iphone ios memory-management ios4

我在 didReceiveMemoryWarning 中收到内存警告。我知道内存警告有不同的级别,如 1 级、2 级。有什么方法可以确定警告级别?示例:

if(warning level == 1)
    <blah>

最佳答案

希望这有帮助!!!

有 4 级警告(0 到 3)。这些是从内核内存观察器设置的,可以通过不那么公开的函数 OSMemoryNotificationCurrentLevel() 获得。

typedef enum {
    OSMemoryNotificationLevelAny      = -1,
    OSMemoryNotificationLevelNormal   =  0,
    OSMemoryNotificationLevelWarning  =  1,
    OSMemoryNotificationLevelUrgent   =  2,
    OSMemoryNotificationLevelCritical =  3
} OSMemoryNotificationLevel;

没有记录级别是如何触发的。 SpringBoard 配置为在每个内存级别执行以下操作:

Warning (not-normal) — Relaunch, or delay auto relaunch of nonessential background apps e.g. Mail.
Urgent — Quit all background apps, e.g. Safari and iPod.
Critical and beyond — The kernel will take over, probably killing SpringBoard or even reboot.

关于iphone - 是否可以确定内存警告的级别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11538154/

相关文章:

iphone - 核心数据 - 保存在后台线程并在主线程中获取

ios - dismissViewControllerAnimated 没有关闭 ViewController

iphone - 为什么在[NSMutableArray array]之后需要此自动释放功能以避免内存泄漏?

iOS 推送通知适用于 iOS 8 但不适用于 iOS SDK 8.1 中的 iOS 7

ios - 仅在 iPhone X (iOS 12) 上以横屏模式使用 UIImagePickerController 时应用程序崩溃

iphone - 如何在 View 释放时安全地取消 ASINetworkQueue 中的所有请求

c# - 在同一个项目中使用不同SDK版本的框架有什么影响?

iphone - UIImagePNGRepresentation() 和比例(iPhone 4 屏幕)

ios - 是否可以在没有索引的情况下使用 Realm 对象服务器实时同步?

c++ - C++中如何使用栈