我在 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/