Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the unit of RSS in psutil.Process.get_memory_info?

Tags:

python

process

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.

like image 769
satoru Avatar asked Aug 01 '13 09:08

satoru


People also ask

What is the unit of RSS?

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.

How does psutil work?

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.

What is Psutil?

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.


1 Answers

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).
like image 166
aychedee Avatar answered Sep 28 '22 10:09

aychedee