Received memory warning.

今天程序在运行的时候收到了以下的信息:

2011-10-27 14:04:42.119 JingDuTianXia[6465:707] Received memory warning. Level=2

2011-10-27 14:04:42.122 JingDuTianXia[6465:707] applicationDidReceiveMemoryWarning

(gdb) continue

Program received signal:  “EXC_BAD_ACCESS”.

关于些内存信息,有以下的通知文件来定义
http://www.opensource.apple.com/source/Libc/Libc-594.1.4/include/libkern/OSMemoryNotification.h

That's the header for kernel code that generates memory warnings, and it declares the following typedef:

这个是关于产生内存警告信息的核心代码头文件,并且它定义了以下的类型

typedef enum {
OSMemoryNotificationLevelAny = -1,
OSMemoryNotificationLevelNormal = 0,
OSMemoryNotificationLevelWarning = 1,
OSMemoryNotificationLevelUrgent = 2,
OSMemoryNotificationLevelCritical = 3
} OSMemoryNotificationLevel;

我们显然没有关于关键方法(OSMemoryNotificationCurrentLevel())的实现,此实现有关于产生何种警告用于返回的逻辑,但以上类型是可能返回的值列表

而我们的工作就是对这些接收到的低内存警告信息进行反映

归根到底,我们要处理接收到的这个内存警告,而不要纠结于产生这些信息的具体逻辑


 

posted @ 2011-10-27 15:07  Piosa  阅读(3409)  评论(0编辑  收藏  举报