mach.h, dumping vm info

#import "mach/mach.h"
....
- (void)logTimer {
  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(@"task_info: %d.2MB\n", info.resident_size / 1048576);
  }
  else {
    NSLog(@"task_info failed with error %d ( 0x%08d ), '%s'\n",
        kerr, kerr, mach_error_string(kerr));
  }
}

Leave a Reply