栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何剖析Python中的内存使用情况?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何剖析Python中的内存使用情况?

在这里已经回答了这个问题:Python memory profiler

基本上,你可以执行以下操作(引用自Guppy-PE):

>>> from guppy import hpy; h=hpy()>>> h.heap()Partition of a set of 48477 objects. Total size = 3265516 bytes. Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)     0  25773  53  1612820  49   1612820  49 str     1  11699  24   483960  15   2096780  64 tuple     2    174   0   241584   7   2338364  72 dict of module     3   3478   7   222592   7   2560956  78 types.CodeType     4   3296   7   184576   6   2745532  84 function     5    401   1   175112   5   2920644  89 dict of class     6    108   0    81888   3   3002532  92 dict (no owner)     7    114   0    79632   2   3082164  94 dict of type     8    117   0    51336   2   3133500  96 type     9    667   1    24012   1   3157512  97 __builtin__.wrapper_descriptor<76 more rows. Type e.g. '_.more' to view.>>>> h.iso(1,[],{})Partition of a set of 3 objects. Total size = 176 bytes. Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)     0      1  33      136  77       136  77 dict (no owner)     1      1  33       28  16       164  93 list     2      1  33       12   7       176 100 int>>> x=[]>>> h.iso(x).sp 0: h.Root.i0_modules['__main__'].__dict__['x']>>> 


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/404738.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号