gc.callbacks

gc.callbacks

A list of callbacks that will be invoked by the garbage collector before and after collection. The callbacks will be called with two arguments, phase and info.

phase can be one of two values:

“start”: The garbage collection is about to start.

“stop”: The garbage collection has finished.

info is a dict providing more information for the callback. The following keys are currently defined:

“generation”: The oldest generation being collected.

“collected”: When phase is “stop”, the number of objects successfully collected.

“uncollectable”: When phase is “stop”, the number of objects that could not be collected and were put in garbage.

Applications can add their own callbacks to this list. The primary use cases are:

Gathering statistics about garbage collection, such as how often various generations are collected, and how long the collection takes.

Allowing applications to identify and clear their own uncollectable types when they appear in garbage.

New in version 3.3.

doc_python
2016-10-07 17:33:28
Comments
Leave a Comment

Please login to continue.