【发布时间】:2019-12-19 01:59:57
【问题描述】:
python 的 gc 包的文档说明了 gc.get_count():
gc.get_count()
Return the current collection counts as a tuple of (count0, count1, count2).
这是一个示例程序:
import gc
if __name__=="__main__":
print("making some data")
for k in range(10):
root = [range(i,1000) for i in range(1,1000)]
print("len(gc.get_objects):",len(gc.get_objects()))
print("gc.get_stats:",gc.get_stats())
print("gc.get_count:",gc.get_count())
这是输出:
making some data
len(gc.get_objects): 7130
gc.get_stats: [{'collections': 16, 'collected': 99, 'uncollectable': 0}, {'collections': 1, 'collected': 0, 'uncollectable': 0}, {'collections': 0, 'collected': 0, 'uncollectable': 0}]
gc.get_count: (75, 5, 1)
显然,count0 = 75,count1=5,count2=1。
count0、count1 和 count2 是什么?
【问题讨论】:
标签: python garbage-collection python-internals