Python内存调优,python调优,在python中可以使用


在python中可以使用guppy做内存调优,guppy是在sourceforge上的开源项目,地址是 http://guppy-pe.sourceforge.net/,有时候可能会访问不了。

guppy的用法很简单:

from guppy import hpyh = hpy()print h.heap()

将会输出类似下面的结果:

Partition of a set of 132527 objects. Total size = 8301532 bytes.Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)0  35144  27  2140412  26   2140412  26 str1  38397  29  1309020  16   3449432  42 tuple2    530   0   739856   9   4189288  50 dict (no owner)

guppy还可以输出占用内存的对象被谁占用了,具体的还有待研究。

评论关闭