gc

Manual control of the garbage collector for benchmarks and tight-loop tuning.

Import

import gc

Functions

gc.collect()

Trigger a garbage collection cycle immediately.

gc.disable()

Disable automatic collection. Manual gc.collect() calls still work.

gc.enable()

Re-enable automatic collection after a gc.disable().

gc.stats() -> map

Return a map of collection counters and current tracked-object counts.

gc.set_threshold(n: int)

Set the allocation count threshold that triggers a young-generation collection.

Examples

scratch.xs