Skip to content
Snippets Groups Projects
Commit b473200c authored by Veronique Legrand's avatar Veronique Legrand
Browse files

now use sysinfo to determine amount of memory available on the machine

parent f259025d
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <iostream> #include <iostream>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <sys/sysinfo.h>
#include "low_level_utils.h" #include "low_level_utils.h"
using namespace std; using namespace std;
...@@ -52,7 +53,16 @@ unsigned long getNodePhysMemory() { ...@@ -52,7 +53,16 @@ unsigned long getNodePhysMemory() {
} }
mem /= 1 * 1024 * 1024 * 1024; mem /= 1 * 1024 * 1024 * 1024;
#else #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 #endif
return (unsigned long)mem; return (unsigned long)mem;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment