python gc

why three?
gc algorithm implement based on three chain, so many informations with three lenth, e.g. threshold
optimize
1: change threshold by automatic gc(default is [700, 0, 0])
2: use weak reference(copy objects)
3: delete when finished

method 3 is the best, but maybe bring the lower develop efficiency;
following is the method 2, use more memory space.
official document
enable() – Enable automatic garbage collection.
disable() – Disable automatic garbage collection.
isenabled() – Returns true if automatic collection is enabled.
collect() – Do a full collection right now.
get_count() – Return the current collection counts.
get_stats() – Return list of dictionaries containing per-generation stats.
set_debug() – Set debugging flags.
get_debug() – Get debugging flags.
set_threshold() – Set the collection thresholds.
get_threshold() – Return the current the collection thresholds.
get_objects() – Return a list of all objects tracked by the collector.
is_tracked() – Returns true if a given object is tracked.
get_referrers() – Return the list of objects that refer to an object.
get_referents() – Return the list of objects that an object refers to.

猜你喜欢

转载自blog.csdn.net/taoxb_csdn/article/details/85611723