关于iPhone App的 Memory warning的一点东西
2013-05-22 12:56
369 查看
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级警告其实比较常见
相关文章推荐
- 关于iPhone App的 Memory warning的一点东西
- 关于iPhone App的 Memory warning的一点东西
- 关于RemoteView的一点愚见(RemoteView在AppWidget中的工作流程)
- 虽然分了Delphi的目录,但是没有写一点关于Delphi的东西,这两天写了一些Delphi的东西,就顺便写到BLOG上吧
- 关于Hibernate的一点东西
- 关于flash嵌入的一点东西 ----遗漏的知识点
- 虽然分了Delphi的目录,但是没有写一点关于Delphi的东西,这两天写了一些Delphi的东西,就顺便写到BLOG上吧
- 关于新建android项目时 appcompat_v7报错问题的一点总结
- 关于iPhone App的错误日志
- 关于目前开发的app中网络数据请求架构的一点思考
- 今天学到的关于UI的一点东西
- 一点关于破解的东西,以后整理整理
- 关于APP自动化工程的一点小想法
- 关于指针的一点东西
- 关于iPad app适配iphone
- 关于File的一点东西
- 关于在iPhone上合并2个应用程序(App)成一个
- 关于flash嵌入的一点东西
- 关于APP自动化工程的一点小想法
- 关于在iPhone上合并2个应用程序(App)成一个