对物理内存的用量检测方法
// 获得当前 App 的内存占用情况
- (NSUInteger)getResidentMemory {
struct task_basic_info t_info;
mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
int r = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);
if (r == KERN_SUCCESS) {
NSLog(@"resident_size %lu",t_info.resident_size / 1024/1024);
return t_info.resident_size;
}
else {
return -1;
}
}