这四个包已经检测到python占据了大约400 3GB,但是当我使用'top -d 1‘时,就会发现它占用了将近3GB的空间!有没有更精确的方法来找出内存泄漏在哪里?
更多信息如下:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
15881 root 20 0 5206548 3.1g 32960 S 0.0 4.9 334:13.48 python3
types | # objects | total size
============================= | =========== | ============
dict | 653590 | 234.98 MB
str | 791447 | 116.25 MB
guppy.sets.setsc.ImmNodeSet | 895 | 47.54 MB
int | 1286323 | 36.75 MB
tuple | 167646 | 14.07 MB
list | 5116 | 6.03 MB
bytes | 77163 | 5.50 MB
code | 38540 | 5.32 MB
type | 5814 | 5.31 MB
set | 2039 | 959.21 KB
weakref | 10108 | 868.66 KB
abc.ABCMeta | 408 | 417.58 KB
getset_descriptor | 5273 | 411.95 KB
cell | 7029 | 384.40 KB
function (__init__) | 2519 | 354.23 KB发布于 2022-10-12 09:27:09
哦,天哪,记忆泄露很难处理
假设这是linux系统,可以从下面开始,看看是否可以隔离大内存区域(PID 15881)。
sudo pmap 15881假设你确定了一个大面积
..
0000558f3f556000 4507556K rw--- [ anon ]
..为了得到范围
sudo cat /proc/15881/maps例如
558f3f556000-559052762000 rw-p 00000000 00:00 0 [heap]使用gdb将该区域附加并转储为文件。
sudo gdb --pid 15881
(gdb) dump memory /tmp/mem.dump 0x558f3f556000 0x559052762000浏览/tmp/mem.dump文件-检查经常出现的部件
strings /tmp/mem.dump恐惧需要一个熟悉你的python应用程序的人来弄清楚
https://stackoverflow.com/questions/74037703
复制相似问题