Skip to content

Instantly share code, notes, and snippets.

@note
Created April 3, 2011 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save note/900393 to your computer and use it in GitHub Desktop.
Save note/900393 to your computer and use it in GitHub Desktop.
int memory_usage(){
char buf[30];
snprintf(buf, 30, "/proc/%u/statm", (unsigned)getpid());
FILE * file = fopen(buf, "r");
setbuf(file, NULL);
unsigned res;
if(file)
fscanf(file, "%u", &res);
fclose(file);
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment