[modules/memory] Use MemAvailable, if present
If the kernel supports it, MemAvailable contains an estimation of the memory available for usage. Use this to calculate the amount of free memory (as this seems to closely match the output of gnome-system-monitor). fixes #253
This commit is contained in:
parent
f3dfd1d577
commit
c45dedb0e8
1 changed files with 4 additions and 1 deletions
|
@ -50,7 +50,10 @@ class Module(bumblebee.engine.Module):
|
|||
if tmp[2] == "mB": value = value*1024*1024
|
||||
if tmp[2] == "gB": value = value*1024*1024*1024
|
||||
data[tmp[0]] = value
|
||||
used = data["MemTotal"] - data["MemFree"] - data["Buffers"] - data["Cached"] - data["Slab"]
|
||||
if "MemAvailable" in data:
|
||||
used = data["MemTotal"] - data["MemAvailable"]
|
||||
else:
|
||||
used = data["MemTotal"] - data["MemFree"] - data["Buffers"] - data["Cached"] - data["Slab"]
|
||||
self._mem = {
|
||||
"total": bumblebee.util.bytefmt(data["MemTotal"]),
|
||||
"available": bumblebee.util.bytefmt(data["MemAvailable"]),
|
||||
|
|
Loading…
Reference in a new issue