Repuesta original de [Travis Gockel][2]

[2]:http://stackoverflow.com/users/254306/travis-gockel

Puede usar [sysconf][3] en sitemas tipo Unix.

[3]:http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html

    #include <unistd.h>
    
    unsigned long long getTotalSystemMemory()
    {
        long pages = sysconf(_SC_PHYS_PAGES);
        long page_size = sysconf(_SC_PAGE_SIZE);
        return pages * page_size;
    }

Para sistemas basados en windows [GlobalMemoryStatusEx][4]:

[4]:https://msdn.microsoft.com/en-us/library/aa366589(VS.85).aspx

    #include <windows.h>
    
    unsigned long long getTotalSystemMemory()
    {
        MEMORYSTATUSEX status;
        status.dwLength = sizeof(status);
        GlobalMemoryStatusEx(&status);
        return status.ullTotalPhys;
    }

[**Pregunta traida de SO**][1]

[1]:http://stackoverflow.com/questions/2513505/how-to-get-available-memory-c-g?noredirect=1&lq=1#2513561