(TIL) Python: Collect garbage

less than 1 minute read

If you have a variable with a large memory footprint, you can force garbage collection using the gc Garbage Collector module:

big_variable = None
gc.collect()  # Run a full garbage collection.

Via python.org.

Comments