Created
February 24, 2010 06:00
-
-
Save nall/313147 to your computer and use it in GitHub Desktop.
Code to get mem usage for OSX process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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