From b473200c71704cc30eec17ec8d206fe8a96633b0 Mon Sep 17 00:00:00 2001 From: Veronique Legrand <vlegrand@pasteur.fr> Date: Mon, 10 May 2021 11:43:17 +0200 Subject: [PATCH] now use sysinfo to determine amount of memory available on the machine --- src/low_level_utils.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/low_level_utils.cpp b/src/low_level_utils.cpp index 7acd6a5..18895fc 100644 --- a/src/low_level_utils.cpp +++ b/src/low_level_utils.cpp @@ -9,6 +9,7 @@ #include <iostream> #include <sys/stat.h> #include <sys/sysctl.h> +#include <sys/sysinfo.h> #include "low_level_utils.h" using namespace std; @@ -52,7 +53,16 @@ unsigned long getNodePhysMemory() { } mem /= 1 * 1024 * 1024 * 1024; #else - cout<<"ROCK has not been tested on this operating system, please contact author."<<endl; + struct sysinfo si; + int ret=sysinfo(&si); + if (ret==-1) { + cout<<"Couldn't determine how much RAM is usable on your system."<<errno<<endl; + mem=0; + } + mem=si.totalram; + mem /= 1 * 1024 * 1024 * 1024; + cout<<"total RAM="<<mem<<endl; +//cout<<"ROCK has not been tested on this operating system, please contact author."<<endl; #endif return (unsigned long)mem; -- GitLab