0

I want to display my my app memory usage in my iphone application Some where like Navigation Bar or adding a subview to UIWindow , so it will be display in all the screens and display the current memory usage

sehaswaran
  • 141
  • 1
  • 8

1 Answers1

1

From: 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));
  }
}
Community
  • 1
  • 1
santibernaldo
  • 825
  • 1
  • 11
  • 26