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
@@ -124,32 +107,26 @@ The :mod:`!gc` module provides the following functions:
124
107
Set the garbage collection thresholds (the collection frequency). Setting
125
108
*threshold0* to zero disables collection.
126
109
127
-
The GC classifies objects into two generations depending on whether they have
128
-
survived a collection. New objects are placed in the young generation. If an
129
-
object survives a collection it is moved into the old generation.
130
-
131
-
In order to decide when to run, the collector keeps track of the number of object
110
+
The GC classifies objects into three generations depending on how many
111
+
collection sweeps they have survived. New objects are placed in the youngest
112
+
generation (generation ``0``). If an object survives a collection it is moved
113
+
into the next older generation. Since generation ``2`` is the oldest
114
+
generation, objects in that generation remain there after a collection. In
115
+
order to decide when to run, the collector keeps track of the number object
132
116
allocations and deallocations since the last collection. When the number of
133
117
allocations minus the number of deallocations exceeds *threshold0*, collection
134
-
starts. For each collection, all the objects in the young generation and some
135
-
fraction of the old generation is collected.
118
+
starts. Initially only generation ``0`` is examined. If generation ``0`` has
119
+
been examined more than *threshold1* times since generation ``1`` has been
120
+
examined, then generation ``1`` is examined as well.
121
+
With the third generation, things are a bit more complicated,
122
+
see `Collecting the oldest generation <https://github.com/python/cpython/blob/ff0ef0a54bef26fc507fbf9b7a6009eb7d3f17f5/InternalDocs/garbage_collector.md#collecting-the-oldest-generation>`_ for more information.
136
123
137
124
In the free-threaded build, the increase in process memory usage is also
138
125
checked before running the collector. If the memory usage has not increased
139
126
by 10% since the last collection and the net number of object allocations
140
127
has not exceeded 40 times *threshold0*, the collection is not run.
141
128
142
-
The fraction of the old generation that is collected is **inversely** proportional
143
-
to *threshold1*. The larger *threshold1* is, the slower objects in the old generation
144
-
are collected.
145
-
For the default value of 10, 1% of the old generation is scanned during each collection.
146
-
147
-
*threshold2* is ignored.
148
-
149
-
See `Garbage collector design <https://devguide.python.org/garbage_collector>`_ for more information.
150
-
151
-
.. versionchanged:: 3.14
152
-
*threshold2* is ignored
129
+
See `Garbage collector design <https://github.com/python/cpython/blob/3.15/InternalDocs/garbage_collector.md>`_ for more information.
0 commit comments