PyDocs

Nav

Python Runtime Services

collect

gc

function
  • collect(generation=2)
Run the garbage collector.

With no arguments, run a full collection.  The optional argument
may be an integer specifying which generation to collect.  A ValueError
is raised if the generation number is invalid.

The number of unreachable objects is returned.
Changed in 3.14, 3.14.5
  • 3.14: generation=1 performs an increment of collection.
  • 3.14.5: generation=1 performs collection of the middle generation.
0 Examples
No examples for gc/collect.
See Also
No see-alsos for gc/collect
0 Notes
No notes for collect