Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use psutil virtual_memory used/free: not reliable. Use total/available instead #462

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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