安装相关包

pip install pyrasite
pip install guppy3
pip install mem_top

使用top查看pid

使用pyrasite连接进程

pyrasite-shell pid

通过pyrasite连接进城后,两种方式打印内存信息:

from guppy import hpy
h = hpy()
h.heap()
from mem_top import mem_top
print(mem_top(limit=15,width=80)) # limit控制显示数据条数,width控制显示数据长度

也可以使用cat /proc/{pid}/status查看进程内存占用

参考:​​https://drmingdrmer.github.io/tech/programming/2017/05/06/python-mem.html​


时间会记录下一切。