Python:记录垃圾收集器 [英] Python: logging the garbage collector
问题描述
我有一个python应用程序,它有一些性能问题。我想添加垃圾收集器的事件(尤其是什么时候被调用)到我的日志中。可能吗?
谢谢。 http://docs.python.org/library/gc.html#gc.set_debug
您可以设置标志,但它们会被写入stderr。
可用标志为
gc.DEBUG_STATS
gc.DEBUG_COLLECTABLE
gc.DEBUG_UNCOLLECTABLE
gc.DEBUG_INSTANCES
gc.DEBUG_OBJECTS
gc.DEBUG_SAVEALL
gc.DEBUG_LEAK
另外
在处理性能时,您可能希望针对详尽的循环或函数调用来剖析代码。您可以使用 cProfile
或 hotshot
。更多这里 http://docs.python.org/library/profile.html
I have a python application that has some performance hiccups. I want to add the garbage collector's events (especially, when does it get called) to my logs. Is it possible?
thanks.
http://docs.python.org/library/gc.html#gc.set_debug
You can set the Flags, but they get written to stderr.
Available flags are
gc.DEBUG_STATS
gc.DEBUG_COLLECTABLE
gc.DEBUG_UNCOLLECTABLE
gc.DEBUG_INSTANCES
gc.DEBUG_OBJECTS
gc.DEBUG_SAVEALL
gc.DEBUG_LEAK
ALSO
When you are dealing with performance, you might wish to profile your code for exhaustive Loops or Function calls. You can use cProfile
or hotshot
. More here http://docs.python.org/library/profile.html
这篇关于Python:记录垃圾收集器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!