@@ -319,10 +319,15 @@ the same object survives another GC round in this new generation (generation 1)
319
319
it will be moved to the last generation (generation 2) where it will be
320
320
surveyed the least often.
321
321
322
- Generations are collected when the number of objects that they contain reaches some
323
- predefined threshold, which is unique for each generation and is lower the older
324
- the generations are. These thresholds can be examined using the ``gc.get_threshold ``
325
- function:
322
+ In order to decide when to run, the collector keeps track of the number of object
323
+ allocations and deallocations since the last collection. When the number of
324
+ allocations minus the number of deallocations exceeds ``threshold_0 ``,
325
+ collection starts. Initially only generation 0 is examined. If generation 0 has
326
+ been examined more than ``threshold_1 `` times since generation 1 has been
327
+ examined, then generation 1 is examined as well. With generation 2,
328
+ things are a bit more complicated; see :ref: `gc-oldest-generation ` for
329
+ more information. These thresholds can be examined using the
330
+ :func: `gc.get_threshold ` function:
326
331
327
332
.. code-block :: python
328
333
@@ -369,6 +374,7 @@ specifically in a generation by calling ``gc.collect(generation=NUM)``.
369
374
[... , < __main__.MyObj object at 0x 7fbcc12a3400> , ... ]
370
375
371
376
377
+ .. _gc-oldest-generation :
372
378
373
379
Collecting the oldest generation
374
380
--------------------------------
0 commit comments