V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
chenqh
V2EX  ›  Python

有没有什么办法可以知道 Python web 是否有内存泄漏

  •  
  •   chenqh · 2017-06-26 11:17:43 +08:00 · 2875 次点击
    这是一个创建于 2467 天前的主题,其中的信息可能已经有所发展或是发生改变。

    现在情况是这样的,今天一起来发现 aws 上 supervisor tornado 进程的内存占用好高,以前一般是一个进程 60M 左右 , 今天基本都是 400M 以上,甚至有 900M 的,有没有办法知道怎么内存泄漏了吗

    5 条回复    2017-06-26 13:02:37 +08:00
    Morriaty
        1
    Morriaty  
       2017-06-26 11:22:27 +08:00   ❤️ 1
    python 有 gc 模块
    jason0916
        2
    jason0916  
       2017-06-26 11:49:49 +08:00
    查看一下有没有全局变量没删除吧?
    chenqh
        3
    chenqh  
    OP
       2017-06-26 12:07:42 +08:00 via iPhone
    @jason0916 我都怀疑是 AWS 的问题了
    kinghui
        4
    kinghui  
       2017-06-26 12:31:20 +08:00   ❤️ 1
    检查一下是否存在相互引用导致 Handler 没有被回收. 因为 Tornado 会为每一个请求构建新的 Handler 处理请求. 如果当前 Handler 的 self 传递给其他对象保存, 同时又把该对应绑定到了 self 上就会产生内存泄露.

    PS. 如果没有引起 OOM 就没啥大问题.
    h280254082
        5
    h280254082  
       2017-06-26 13:02:37 +08:00   ❤️ 1
    有一个叫 meliae 的库你可以看一眼
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1702 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 16:44 · PVG 00:44 · LAX 09:44 · JFK 12:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.