【问题标题】:How to display memory usage of my application in my iphone application如何在我的 iphone 应用程序中显示我的应用程序的内存使用情况
【发布时间】:2014-03-21 11:28:07
【问题描述】:

我想在我的 iphone 应用程序中显示我的应用程序内存使用情况 一些像 Navigation Bar 或向 UIWindow 添加子视图的地方,因此它将显示在所有屏幕中并显示当前内存使用情况

【问题讨论】:

  • 您是在询问设备上的应用实时内存(运行内存)还是应用文件夹内存?

标签: ios iphone ios7 ios6 ios7.1


【解决方案1】:

发件人:Programmatically retrieve memory usage on 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 in use (in bytes): %u", info.resident_size);
  } else {
    NSLog(@"Error with task_info(): %s", mach_error_string(kerr));
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-02
    • 2011-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    相关资源
    最近更新 更多