简体   繁体   English

如何分析python进程的内存使用情况?

[英]How to profile python process for memory usage?

We own a corporate level forum which is developed using python (with Django framework). 我们拥有一个公司级论坛,该论坛是使用python(使用Django框架)开发的。 We are intermittently observing memory usage spikes on our production setup and we wish to track the cause. 我们会间歇性地观察生产设置中的内存使用量激增情况 ,并希望找出原因。

The occurrences of these incidences are random and not directly related to the load (as per current study). 这些事件的发生是随机的 ,与负荷没有直接关系(根据当前研究)。

I have browsed a lot on internet and especially stackoverflow for some suggestions and was not able to get any similar situation. 我在互联网上浏览了很多内容,尤其是在stackoverflow上获得了一些建议,但无法得到任何类似的情况。

Yes, I was able to locate a lot of profiler utils like Python memory profiler but these require some code level inclusion of these modules and as this happens to be in production profiler are not a great help (we plan to review our implementation in the next release). 是的,我能够找到许多探查器实用程序,例如Python内存探查器,但是这些需要一些代码级包含这些模块,并且由于恰好在生产探查器中,所以它并不是一个很大的帮助(我们计划在下一个中回顾我们的实现发布)。

We wish to review this issue based on occurrence. 我们希望根据发生情况复查此问题。

Thus I wish to check whether there is any tool that we can use to create a dump for analysis offline (just like heapdumps in java). 因此,我希望检查是否可以使用任何工具来创建用于脱机分析的转储(就像Java中的heapdumps一样)。

Any pointers? 有指针吗? Is gdb the only option? gdb是唯一的选择吗?

OS: Linux Python: 2.7 (currently we do not plan to upgrade until that can help in fixing this issue) 操作系统:Linux Python:2.7(当前,我们不打算升级,直到可以解决此问题为止)

Cheers! 干杯!

AJ AJ

maybe you can try using valgrind. 也许您可以尝试使用valgrind。 It's a bit tricky, but you can follow up here if you are interested in it 这有点棘手,但是如果您对此感兴趣的话,可以在这里跟进

How to use valgrind with python? 如何在python中使用valgrind?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM