我有一个numpy
脚本 - 根据top
- 正在使用大约 5GB 的 RAM:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
16994 aix 25 0 5813m 5.2g 5.1g S 0.0 22.1 52:19.66 ipython
是否有内存分析器可以让我了解占用大部分内存的对象?
我试过了heapy
,但guppy.hpy().heap()
给了我这个:
Partition of a set of 90956 objects. Total size = 12511160 bytes.
Index Count % Size % Cumulative % Kind (class / dict of class)
0 42464 47 4853112 39 4853112 39 str
1 22147 24 1928768 15 6781880 54 tuple
2 287 0 1093352 9 7875232 63 dict of module
3 5734 6 733952 6 8609184 69 types.CodeType
4 498 1 713904 6 9323088 75 dict (no owner)
5 5431 6 651720 5 9974808 80 function
6 489 1 512856 4 10487664 84 dict of type
7 489 1 437704 3 10925368 87 type
8 261 0 281208 2 11206576 90 dict of class
9 1629 2 130320 1 11336896 91 __builtin__.wrapper_descriptor
<285 more rows. Type e.g. '_.more' to view.>
出于某种原因,它只占 5GB 中的 12MB(大部分内存几乎肯定被numpy
阵列使用)。
关于我可能做错了heapy
什么或我应该尝试哪些其他工具(除了这个线程中已经提到的那些)的任何建议?