eddys_snippets/get_avail_mem.c
2018-03-25 10:50:23 +03:00

15 lines
400 B
C

#include <stdio.h>
#include <unistd.h>
static unsigned long long get_available_mem(){
return sysconf(_SC_AVPHYS_PAGES) * (unsigned long long) sysconf(_SC_PAGE_SIZE);
}
int main(){
unsigned long long m = get_available_mem();
printf("MEM: %llu == %lluGB\n", m, m/1024/1024/1024);
return 0;
}
// Never allocate memory by big pieces with malloc! Only mmap with MAP_POPULATE!!!!!!!!!11111111111