![](/img/trans.png)
[英]How to get memory usage of my application and system in swift by programatically
[英]How to display memory usage of my application in my iphone application
我想在iPhone应用程序中显示我的应用程序内存使用情况,例如导航栏或向UIWindow添加子视图,因此它将显示在所有屏幕中并显示当前内存使用情况
#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));
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.