关于iPhone App的 Memory warning的一点东西

iPhone App 现在进入到了iOS4时代,内存问题越来越重要了,以前的iOS都是单任务的,内存还算够用,现在iOS4推出了多任务系统,越来越多的程序占了内存以后,在后台又不释放,使用者也往往会忘记在后台杀掉其他程序的进程,导致现在的程序经常会遇到内存不够用的情况,真不知道这个多任务系统是好是坏丫。

总之,作为一个程序员,有bug就得处理,没办法。。。
接收到内存不够警告很有必要,使用
- (void)didReceiveMemoryWarning {
         [super didReceiveMemoryWarning];
         //TO DO:
}
如果内存不够用,这个方法就能触发了。这时候,建议你释放一些必不要的数据以便腾出足够的内存。

好吧,我承认前面都是废话,下面写点有用的, 关于内存警告级别的解释:

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:
    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.
Killing the active app (jetsam) is not handled by SpringBoard, but launchd.

根据我的理解,2级以前的警告都可以无视,2级的警告老实说,有点危险,但是我个人的体会是,其实也可以凑合了^_^
因为你如果使用了照相机的话,2级警告其实比较常见

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值