简体   繁体   English

psutil.Process.get_memory_info中RSS的单位是什么?

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

When I use ps -o pid,rss -p 1 , I see the following: 当我使用ps -o pid,rss -p 1 ,我看到以下内容:

PID RSS
  1 784

But when I query for rss with psutil , I get a different value: 但是当我用psutil查询rss时,我得到一个不同的值:

>>> p = psutil.Process(1)
>>> print p.get_memory_info().rss
802816

Is it possible that psutil uses a different unit? psutil可能使用不同的单位吗? I can't find any related information in the documentation . 我在文档中找不到任何相关信息。

The output of ps is in kiloBytes. ps的输出以千字节为单位。 RSS (resident set size) from psutil is in bytes. 来自psutil的RSS(驻留集大小)以字节为单位。

>>> 802816 / 784
1024 

From man ps : 来自man ps

rss         RSS       resident set size, the non-swapped physical 
           memory that a task has used (in kiloBytes).  (alias rssize, rsz).
import os
import psutil
process = psutil.Process(os.getpid())
print(process.memory_info().rss)  # in bytes 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM