Description
Describe the bug
On Linux, ROOT reports most of the RAM is full, even if it is free. Probably because it reports:
used = total - free
instead of
used = total - free - cached = total - available
See:
root/core/unix/src/TUnixSystem.cxx
Line 5153 in 4d2a865
/opt/root_bld/tutorials/gui $ root -l
root [0] MemInfo_t memInfo; gSystem->GetMemInfo(&memInfo);
root [1] cout << memInfo.fMemTotal << " " << memInfo.fMemUsed << " " << memInfo.fMemFree << endl;
15933 15381 552
root [2] .q
/opt/root_bld/tutorials/gui $ free -h
total used free shared buff/cache available
Mem: 15G 5.6G 658M 439M 9.3G 9.2G
Swap: 1.0G 135M 888M
Expected behavior
It should report the actual free memory, or add a new variable inside the MemInfo_t struct that specifies the 9.3 'cached' memory, which is actually free to use.
To Reproduce
MemInfo_t memInfo; gSystem->GetMemInfo(&memInfo);
cout << memInfo.fMemTotal << " " << memInfo.fMemUsed << " " << memInfo.fMemFree << endl;
or
/opt/root_bld/tutorials/gui $ root -l CPUMeter.C
Setup
- ROOT version: 6.23/01
- Operating system: Ubuntu 18
- Self-built
Additional context
https://www.thegeekdiary.com/understanding-proc-meminfo-file-analyzing-memory-utilization-in-linux/
My suggestion to solve this would be to do:
if (s.BeginsWith("MemAvailable")) {
TPRegexp("^.+: *([^ ]+).*").Substitute(s, "$1");
meminfo->fMemAvailable = (s.Atoi() / 1024);
}
meminfo->fMemUsed = meminfo->fMemTotal - meminfo->fMemAvailable;
and then in https://root.cern/doc/master/structMemInfo__t.html#a62b63e5e24efd2e2b5d0f60456e239d6:
Int_t fMemAvailable; // available RAM in MB
For the SWAP it's probably not necessary.
Not sure if the same issue happens for other OS.
Metadata
Metadata
Assignees
Type
Projects
Status