Skip to content

Instantly share code, notes, and snippets.

@beelsebob
Created November 4, 2011 14:33
Show Gist options
  • Select an option

  • Save beelsebob/1339457 to your computer and use it in GitHub Desktop.

Select an option

Save beelsebob/1339457 to your computer and use it in GitHub Desktop.
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)
{
static vm_size_t last_resident_size = 0;
if(last_resident_size != info.resident_size)
{
last_resident_size = info.resident_size;
NSLog(@"Memory usage: %u", last_resident_size);
}
static natural_t last_virtual_size = 0;
if(last_virtual_size != info.virtual_size)
{
last_virtual_size = info.virtual_size;
NSLog(@"Virtual memory usage: %u", last_virtual_size);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment