You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Doc/library/gc.rst
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,12 +124,13 @@ The :mod:`!gc` module provides the following functions:
124
124
generation (generation ``0``). If an object survives a collection it is moved
125
125
into the next older generation. Since generation ``2`` is the oldest
126
126
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.
133
134
With the third generation, things are a bit more complicated,
134
135
see `Collecting the oldest generation <https://github.com/python/cpython/blob/ff0ef0a54bef26fc507fbf9b7a6009eb7d3f17f5/InternalDocs/garbage_collector.md#collecting-the-oldest-generation>`_ for more information.
0 commit comments