Django内存泄漏:可能的原因? [英] Django memory leak: possible causes?

查看:304
本文介绍了Django内存泄漏:可能的原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Django应用程序,每隔一段时间就会陷入内存泄漏.

I've a Django application that every so often is getting into memory leak.

我使用的不是大数据,可能会使内存超载,实际上,应用程序会逐渐消耗"内存(一周内内存从约70 MB变为4GB),这就是为什么我怀疑垃圾收集器缺少某些内容的原因,但我不确定.而且,这种增加似乎与请求数无关.

I am not using large data that could overload the memory, in fact the application 'eats' memory incrementally (in a week the memory goes from ~ 70 MB to 4GB), that is why I suspect the garbage collector is missing something, I am not sure though. Also, it seems as this increment is not dependant of the number of requests.

明显的内容,例如DEBUG=True,保留打开的文件等...在这里不适用.

Obvious things like DEBUG=True, leaving open files, etc... no apply here.

我正在使用uWSGI 2.0.3(+ nginx)和Django 1.4.5

I'm using uWSGI 2.0.3 (+ nginx) and Django 1.4.5

我可以设置wsgi,以便在内存超过特定限制时重新启动服务器,但是我不愿意这样做,因为那实际上不是解决方案.

I could set up wsgi so that restart the server when the memory exceeds certain limit, but I wouldn't like to do that since that is not a solution really.

是否有众所周知的情况,垃圾收集器无法正常工作"?可以提供一些代码示例吗?

Are there any well know situations where the garbage collector "doesn't do its work properly"? Could it provide some code examples?

是否存在可能导致uWSGI + Django的任何配置?

Is there any configuration of uWSGI + Django that could cause this?

推荐答案

我没有找到我想要的确切东西(每个项目都是一个世界!),但是根据一些线索和建议,我设法解决了问题.我与您分享一些链接,如果您遇到类似的问题,这些链接可能会有所帮助.

I haven't found the exact stuff I'm looking for (each project is a world!), but following some clues and advices I managed to solve the issue. I share with you a few links that could help if you are facing a similar problem.

django内存泄漏,第一部分 django内存泄漏,第二部分在ubuntu 12.04上针对nginx和uwsgi进行了优化的脚本(用于WEB2PY,但通过uWSGI)和调试WSGI应用程序中的内存泄漏.

一些有用的SO答案/问题: 建议使用哪种Python内存分析器? Python内存泄漏 Python:内存泄漏调试

Some useful SO answers/questions: Which Python memory profiler is recommended?, Is there any working memory profiler for Python3, Python memory leaks and Python: Memory leak debugging

这篇关于Django内存泄漏:可能的原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆