首页 文章

django和guppy找到哪个导入需要更多内存

提问于
浏览
0

我按照这个tutorial来安装孔雀鱼和配置文件我的django应用程序 . 我的django应用程序没有内存泄漏,但由于一些奇怪的原因,它需要Apache / mod_wsgi环境中的大量内存 . 有人告诉我,我的一个进口可能是导致这个问题的原因 .

如何使用guppy查看哪个导入消耗更多内存? guppy输出对我的水平来说并不那么有用 . 这里是:

*** Connection 1 opened ***
<Monitor> lc
CID PID  ARGV
  1 2056 ['manage.py', 'runserver']
<Monitor> sc 1
Remote connection 1. To return to Monitor, type <Ctrl-C> or .<RETURN>
<Annex> int
Remote interactive console. To return to Annex, type '-'.
>>> hp.heap()
GC hook object was referred to from somebody!
Partition of a set of 128202 objects. Total size = 11015508 bytes.
 Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
     0  55746  43  4117640  37   4117640  37 str
     1  29278  23  1272920  12   5390560  49 tuple
     2   2457   2   777324   7   6167884  56 dict (no owner)
     3    495   0   583860   5   6751744  61 dict of module
     4   8361   7   501660   5   7253404  66 function
     5   7202   6   489736   4   7743140  70 types.CodeType
     6   1026   1   461748   4   8204888  74 type
     7   1022   1   402472   4   8607360  78 dict of type
     8    179   0   250852   2   8858212  80 dict of django.db.models.fields.CharField
     9   2599   2   156124   1   9014336  82 list
<486 more rows. Type e.g. '_.more' to view.>

1 回答

  • 1

    FWIW . Python Web应用程序在Apache / mod_wsgi下消耗的内存比在不同的WSGI服务器(如uWSGI或gunicorn)下消耗更多内容没有具体原因 . 在可比较配置下,Web应用程序的每进程内存要求应与您的应用程序不会以不同方式运行的大致相同 . 关于唯一可能产生影响的是服务器配置是否是多线程的,并且您正在与单线程配置进行比较 .

    还要小心你正在考虑的记忆量 . 使用RSS而不是虚拟内存大小 . 看到:

    http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Memory_Constrained_VPS_Systems

相关问题