snipplets.dev/code/C/get_ram_usage.c

12 lines
198 B
C

#include <sys/resource.h>
#include <stdio.h>
int main() {
struct rusage r_usage;
getrusage(RUSAGE_SELF, &r_usage);
printf("Memory usage: %ld kilobytes\n", r_usage.ru_maxrss);
return 0;
}