[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,6 +50,9 @@ class Module(bumblebee.engine.Module):
|
||||||
if tmp[2] == "mB": value = value*1024*1024
|
if tmp[2] == "mB": value = value*1024*1024
|
||||||
if tmp[2] == "gB": value = value*1024*1024*1024
|
if tmp[2] == "gB": value = value*1024*1024*1024
|
||||||
data[tmp[0]] = value
|
data[tmp[0]] = value
|
||||||
|
if "MemAvailable" in data:
|
||||||
|
used = data["MemTotal"] - data["MemAvailable"]
|
||||||
|
else:
|
||||||
used = data["MemTotal"] - data["MemFree"] - data["Buffers"] - data["Cached"] - data["Slab"]
|
used = data["MemTotal"] - data["MemFree"] - data["Buffers"] - data["Cached"] - data["Slab"]
|
||||||
self._mem = {
|
self._mem = {
|
||||||
"total": bumblebee.util.bytefmt(data["MemTotal"]),
|
"total": bumblebee.util.bytefmt(data["MemTotal"]),
|
||||||
|
|
Loading…
Reference in a new issue