Python内存泄漏 [英] Python memory leaks
本文介绍了Python内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个长期运行的脚本,如果让它运行足够长的时间,将消耗系统上的所有内存。
I have a long-running script which, if let to run long enough, will consume all the memory on my system.
没有详细介绍脚本,我有两个问题:
Without going into details about the script, I have two questions:
- 是否有任何最佳做法可以跟踪,这有助于防止发生泄漏?
- 有什么技术来调试Python中的内存泄漏?
推荐答案
看看这篇文章:跟踪python内存泄漏
另外请注意,垃圾收集模块实际上可以设置调试标志。看看set_debug函数。另外,查看 Gnibbler的这段代码,以确定对象的类型已在通话后创建。
Also, note that the garbage collection module actually can have debug flags set. Look at the set_debug function. Additionally, look at this code by Gnibbler for determining the types of objects that have been created after a call.
这篇关于Python内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文