Created
August 12, 2016 05:45
-
-
Save was0107/3bf0436da6fc7cb4078a5cce7a8096e5 to your computer and use it in GitHub Desktop.
getMemoryUsage
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
#pragma mark - Memory methods | |
double getMemoryUsage(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); | |
double memoryUsageInMB = kerr == KERN_SUCCESS ? (info.resident_size / 1024.0 / 1024.0) : 0.0; | |
return memoryUsageInMB; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment