Skip to content

Instantly share code, notes, and snippets.

@nall
Created February 24, 2010 06:00
Show Gist options
  • Save nall/313147 to your computer and use it in GitHub Desktop.
Save nall/313147 to your computer and use it in GitHub Desktop.
Code to get mem usage for OSX process
#include <mach/task.h>
int getmem (vm_size_t *rss, vm_size_t *vs)
{
struct task_basic_info t_info;
mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
if (KERN_SUCCESS != task_info(mach_task_self(),
TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count))
{
return -1;
}
*rss = t_info.resident_size;
*vs = t_info.virtual_size;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment