iPhone 内存使用情况

标签 iphone

有没有办法记录您的应用程序当前使用了多少内存?

最佳答案

#import <mach/mach.h>


void report_memory(void) {
  struct task_basic_info info;
  mach_msg_type_number_t size = sizeof(info);
  kern_return_t kerr = task_info(mach_task_self(),
                                 TASK_BASIC_INFO,
                                 (task_info_t)&info,
                                 &size);
  if( kerr == KERN_SUCCESS ) {
    NSLog(@"Memory used: %u", info.resident_size); //in bytes
  } else {
    NSLog(@"Error: %s", mach_error_string(kerr));
  }
}

关于iPhone 内存使用情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2786539/

相关文章:

php - exif 在移动设备上使用 php 上传图片时剥离 GPS header ?

iphone - 增加 tabBarItem 图像大小

iphone - 基于服务器的数据库

ios - 推送 View Controller 未在 ios 7 上推送

iphone 开发 : communicating with server and push to anotherview

iphone - 以编程方式在表格单元格中添加 UISegmentedControl 并具有清晰的背景

iphone - UIApplicationDidEnterBackgroundNotification

iphone - NS正则表达式 : Replace url text with <a> tags

iphone - 选择器方法从未在 NSNotificationCenter 中调用

iphone - 在滑动通知解锁后将用户重定向到我的应用程序的特定屏幕