Skip to content

Commit

Permalink
Merge pull request #462 from mathoudebine/fix/450-used-ram-meaningles…
Browse files Browse the repository at this point in the history
…s-on-linux-+-give-wrong-total
  • Loading branch information
mathoudebine authored Jan 30, 2024
2 parents ebc32cd + c3257df commit 08b769b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions library/sensors/sensors_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,15 @@ def virtual_percent() -> float:

@staticmethod
def virtual_used() -> int: # In bytes
return psutil.virtual_memory().used
# Do not use psutil.virtual_memory().used: from https://psutil.readthedocs.io/en/latest/#memory
# "It is calculated differently depending on the platform and designed for informational purposes only"
return psutil.virtual_memory().total - psutil.virtual_memory().available

@staticmethod
def virtual_free() -> int: # In bytes
return psutil.virtual_memory().free
# Do not use psutil.virtual_memory().free: from https://psutil.readthedocs.io/en/latest/#memory
# "note that this doesn’t reflect the actual memory available (use available instead)."
return psutil.virtual_memory().available


class Disk(sensors.Disk):
Expand Down

0 comments on commit 08b769b

Please sign in to comment.