Created
June 11, 2014 12:50
-
-
Save pykello/49e1c8341376b913e3b6 to your computer and use it in GitHub Desktop.
This file contains 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
static uint64 get_memory_usage() { | |
uint64 result = 0; | |
int i = 0; | |
bool seenSpace = false; | |
char statm[1024]; | |
FILE *statmFile = fopen("/proc/self/statm", "r"); | |
fread(statm, 1, 1024, statmFile); | |
fclose(statmFile); | |
for (i = 0; i < 1024; i++) { | |
if (!seenSpace) { | |
if (statm[i] == ' ') { | |
seenSpace = true; | |
} | |
} | |
else { | |
if (statm[i] == ' ') { | |
break; | |
} | |
else { | |
result = result * 10 + (statm[i] - '0'); | |
} | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment