When I use ps -o pid,rss -p 1
, I see the following:
PID RSS
1 784
But when I query for rss
with psutil
, I get a different value:
>>> p = psutil.Process(1)
>>> print p.get_memory_info().rss
802816
Is it possible that psutil
uses a different unit?
I can't find any related information in the documentation.
In Linux, process memory utilization is measured by two values, VSZ and RSS (both measured in bytes). RSS stands for Resident Set Size and shows how much RAM is utilized at the time the command is output. It also should be noted that it shows the entire stack of physically allocated memory.
Psutil is a Python cross-platform library used to access system details and process utilities. It is used to keep track of various resources utilization in the system. Usage of resources like CPU, memory, disks, network, sensors can be monitored.
psutil (python system and process utilities) is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network, sensors) in Python. It is useful mainly for system monitoring, profiling, limiting process resources and the management of running processes.
The output of ps is in kiloBytes. RSS (resident set size) from psutil is in bytes.
>>> 802816 / 784
1024
From man ps
:
rss RSS resident set size, the non-swapped physical
memory that a task has used (in kiloBytes). (alias rssize, rsz).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With