gc.freeze()
gc.freeze() is a Python function in the GC Module category. Freezes all tracked objects, preventing them from being collected. The syntax is gc.freeze(). Returns: None. A typical example: gc.freeze() # Optimize for long-running processes. A close sibling is gc.collect(), which runs the garbage collector. Returns the number of unreachable objects collected. A close sibling is gc.get_objects(), which returns a list of all objects tracked by the garbage collector. A close sibling is gc.set_threshold(), which sets the garbage collection thresholds for each generation. A close sibling is gc.get_threshold(), which returns the current GC thresholds as a tuple. More about this category: Garbage collector — collect, get_objects, set_threshold, get_stats. Related GC Module entries: gc.collect(), gc.get_objects(), gc.set_threshold(), gc.get_threshold(), gc.get_count(), gc.set_debug(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try gc.freeze() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.