On this page
gc.set_debug
Prev: gc.isenabled | Up: gc | Next: gc.set_threshold
Rel: gc.collect, gc.disable, gc.enable, gc.freeze
Ref: docs.python.org — gc.set_debug
Tags: #public #python3 #stdlib #gc
Import
import gc
from gc import set_debug
Signature & Overview
gc.set_debug(flags, /)
Set the garbage collection debugging flags.
Usage
import gc
old = gc.get_debug()
gc.set_debug(0)
try:
assert gc.get_debug() == 0
finally:
gc.set_debug(old)
Gotchas
- Reset to
0after debugging: Flags likegc.DEBUG_SAVEALLintentionally retain every collected object ingc.garbage, which leaks memory if left on.
REPL Inspect
from gc import set_debug
help(set_debug)
Linked from
Related notes
- tuts/python3/stdlib_module/gc/isenabled Linked here; links to this page; shared tags: #gc, #stdlib
- tuts/python3/stdlib_module/gc/set_threshold 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