我想在我的iphone应用程序中显示我的应用内存使用情况 一些像导航栏或向UIWindow添加子视图的地方,所以它将在所有屏幕中显示并显示当前的内存使用情况
答案 0 :(得分: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));
}
}