On this page
gc.set_threshold
Prev: gc.set_debug | Up: gc | Next: gc.unfreeze
Rel: gc.collect, gc.disable, gc.enable, gc.freeze
Ref: docs.python.org — gc.set_threshold
Tags: #public #python3 #stdlib #gc
Import
import gc
from gc import set_threshold
Signature & Overview
gc.set_threshold(threshold0, [threshold1, [threshold2]])
Set the collection thresholds (the collection frequency).
Usage
import gc
old = gc.get_threshold()
gc.set_threshold(*old)
assert gc.get_threshold() == old
Gotchas
- Tune only after profiling GC pauses (
gc.get_stats()).
REPL Inspect
from gc import set_threshold
help(set_threshold)
Linked from
Related notes
- tuts/python3/stdlib_module/gc/set_debug Linked here; links to this page; shared tags: #gc, #stdlib
- tuts/python3/stdlib_module/gc/unfreeze Linked here; links to this page; shared tags: #gc, #stdlib
- tuts/python3/stdlib_module/gc Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/gc/collect Linked here; shared tags: #gc, #stdlib
- tuts/python3/stdlib_module/gc/disable Linked here; shared tags: #gc, #stdlib
- tuts/python3/stdlib_module/gc/enable Linked here; shared tags: #gc, #stdlib
- tuts/python3/stdlib_module/gc/freeze Linked here; shared tags: #gc, #stdlib
- tuts/python3/stdlib_module/gc/get_count shared tags: #gc, #stdlib
- tuts/python3/stdlib_module/gc/get_debug shared tags: #gc, #stdlib
- tuts/python3/stdlib_module/gc/get_freeze_count shared tags: #gc, #stdlib