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
fcicq
V2EX  ›  Python

请问如何解决 python-memcache 内存泄漏

  •  
  •   fcicq · 2011-09-26 13:05:43 +08:00 · 6150 次点击
    这是一个创建于 4597 天前的主题,其中的信息可能已经有所发展或是发生改变。
    应用是 webapp2 + gevent 做的. 应用有需要用 gevent 进行的异步操作, 所以无法使用 libmemcached 的 bindings. 使用 Dozer 已经确认泄漏出现在 memcache.Client. python-memcache 版本 1.40-2ubuntu1, python 版本 2.6.4~rc2-0ubuntu1.

    大致目前的使用方式:
    def get_mc():
    mc = memcache.Client([MEMCACHE_SERVER], debug=0)
    return mc
    ... (略)
    def mc_free(mc):
    mc.disconnect_all()

    然后
    mc = get_mc()
    ...
    mc_free(mc)
    del mc

    但不幸的是该 object 仍然没有被回收.

    全局的 memcache.Client 实例, 在同时被使用(gevent)时会引发竞态(也不适合加锁), 故提此问题.
    5 条回复    1970-01-01 08:00:00 +08:00
    fcicq
        1
    fcicq  
    OP
       2011-09-26 13:24:41 +08:00
    solved, by apt-get remove python-memcache and easy-install python-memcached
    qichangxing
        2
    qichangxing  
       2011-09-27 10:18:58 +08:00
    看下这个是否有助参考: http://simple-is-better.com/news/350
    fcicq
        3
    fcicq  
    OP
       2011-09-27 13:25:20 +08:00
    已经解决了... 不要再回了.
    yangjuven
        4
    yangjuven  
       2011-11-23 11:12:39 +08:00
    @fcicq 楼主,问题虽然已经通过"easy_install python-memcached",但是memory leak在哪个点?为什么这个方法能解决?并没有说清哦。望指明。最近也碰到了这个问题。
    fcicq
        5
    fcicq  
    OP
       2011-11-24 16:50:57 +08:00
    版本更新
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   871 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:45 · PVG 05:45 · LAX 14:45 · JFK 17:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.