Skip to content

Commit 50e03c5

Browse files
committed
gh-122862: Fix description of the GC allocation counter in set_threshold() docs
1 parent 161054c commit 50e03c5

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Doc/library/gc.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,13 @@ The :mod:`!gc` module provides the following functions:
124124
generation (generation ``0``). If an object survives a collection it is moved
125125
into the next older generation. Since generation ``2`` is the oldest
126126
generation, objects in that generation remain there after a collection. In
127-
order to decide when to run, the collector keeps track of the number object
128-
allocations and deallocations since the last collection. When the number of
129-
allocations minus the number of deallocations exceeds *threshold0*, collection
130-
starts. Initially only generation ``0`` is examined. If generation ``0`` has
131-
been examined more than *threshold1* times since generation ``1`` has been
132-
examined, then generation ``1`` is examined as well.
127+
order to decide when to run, the collector keeps a counter that is reset by
128+
each collection, incremented by each object allocation, and decremented by
129+
each object deallocation, but never below zero. When this counter exceeds
130+
*threshold0*, collection starts. Initially only generation ``0`` is
131+
examined. If generation ``0`` has been examined more than *threshold1* times
132+
since generation ``1`` has been examined, then generation ``1`` is examined
133+
as well.
133134
With the third generation, things are a bit more complicated,
134135
see `Collecting the oldest generation <https://github.com/python/cpython/blob/ff0ef0a54bef26fc507fbf9b7a6009eb7d3f17f5/InternalDocs/garbage_collector.md#collecting-the-oldest-generation>`_ for more information.
135136

0 commit comments

Comments
 (0)