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
@@ -101,19 +118,27 @@ The :mod:`gc` module provides the following functions:
101
118
Set the garbage collection thresholds (the collection frequency). Setting
102
119
*threshold0* to zero disables collection.
103
120
104
-
The GC classifies objects into three generations depending on how many
105
-
collection sweeps they have survived. New objects are placed in the youngest
106
-
generation (generation ``0``). If an object survives a collection it is moved
107
-
into the next older generation. Since generation ``2`` is the oldest
108
-
generation, objects in that generation remain there after a collection. In
109
-
order to decide when to run, the collector keeps track of the number object
121
+
The GC classifies objects into two generations depending on whether they have
122
+
survived a collection. New objects are placed in the young generation. If an
123
+
object survives a collection it is moved into the old generation.
124
+
125
+
In order to decide when to run, the collector keeps track of the number of object
110
126
allocations and deallocations since the last collection. When the number of
111
127
allocations minus the number of deallocations exceeds *threshold0*, collection
112
-
starts. Initially only generation ``0`` is examined. If generation ``0`` has
113
-
been examined more than *threshold1* times since generation ``1`` has been
114
-
examined, then generation ``1`` is examined as well.
115
-
With the third generation, things are a bit more complicated,
116
-
see `Collecting the oldest generation <https://devguide.python.org/garbage_collector/#collecting-the-oldest-generation>`_ for more information.
128
+
starts. For each collection, all the objects in the young generation and some
129
+
fraction of the old generation is collected.
130
+
131
+
The fraction of the old generation that is collected is **inversely** proportional
132
+
to *threshold1*. The larger *threshold1* is, the slower objects in the old generation
133
+
are collected.
134
+
For the default value of 10, 1% of the old generation is scanned during each collection.
135
+
136
+
*threshold2* is ignored.
137
+
138
+
See `Garbage collector design <https://devguide.python.org/garbage_collector>`_ for more information.
0 commit comments