Memory level warnings are logged by SpringBoard. As an app developer you don't need to care about it. Just responding to -{application}didReceiveMemoryWarning
is enough.
There are 4 levels of warnings (0 to 3). These are set from the kernel memory watcher, and can be obtained by the not-so-public function OSMemoryNotificationCurrentLevel()
.
typedef enum {
OSMemoryNotificationLevelAny = -1,
OSMemoryNotificationLevelNormal = 0,
OSMemoryNotificationLevelWarning = 1,
OSMemoryNotificationLevelUrgent = 2,
OSMemoryNotificationLevelCritical = 3
} OSMemoryNotificationLevel;
How the levels are triggered is not documented. SpringBoard is configured to do the following in each memory level:
- 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.
Killing the active app (jetsam) is not handled by SpringBoard, but launchd
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…