From 08b2beb3390bef0bc029bed6e8fdb78592d104d2 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 18 Sep 2014 15:55:25 +1000 Subject: [PATCH] Report available RAM on linux. --- src/config/hardware_stats.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/config/hardware_stats.cpp b/src/config/hardware_stats.cpp index 8e11f5503..8f92a3f9b 100644 --- a/src/config/hardware_stats.cpp +++ b/src/config/hardware_stats.cpp @@ -26,6 +26,24 @@ namespace HardwareStats { + + +// ---------------------------------------------------------------------------- +/** Returns the amount of RAM in MB. + */ +int getRAM() +{ +#ifdef __linux__ + const uint64_t memorySize = (uint64_t)sysconf(_SC_PHYS_PAGES) + * sysconf(_SC_PAGESIZE); + return long(memorySize / (1024*1024)); +#endif + + return 0; +} // getRAM + +// ---------------------------------------------------------------------------- + void reportHardwareStats() { Json json; @@ -75,6 +93,11 @@ void reportHardwareStats() json.add("video_xres", UserConfigParams::m_width ); json.add("video_yres", UserConfigParams::m_height); + + int mem = getRAM(); + if(mem>0) + json.add("ram_total", mem); + // Too long for debugging atm //json.add("GL_EXTENSIONS", getGLExtensions()); json.finish();