OSMemoryNotification.h
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:
1.Warning (not-normal) — Relaunch, or delay auto relaunch of nonessential background apps e.g. Mail.
2.Urgent — Quit all background apps, e.g. Safari and iPod.
3.Critical and beyond — The kernel will take over, probably killing SpringBoard or even reboot.
4.Killing the active app (jetsam) is not handled by SpringBoard, but launchd.
參考文章
在cocos2d呢
1 .Received memory warning. Level= 1
會觸發 [[CCDirector sharedDirector] purgeCachedData];
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
[[CCDirector sharedDirector] purgeCachedData];
}
此時會把目前沒用到的 材質釋放掉~~
~
理論上ios系統會把不必要的背景程式關掉~
遇到這個情形呢~ 先查查leak吧
如果都沒有~就就就就…砍需求or改需求or改code~~~
減少在同一畫面下的內存使用量了
2 .Received memory warning. Level= 2
目前遇到的都crash 掉了~
還是乖乖查leak …
其他的還沒遇過~哈