Garbage Collector
say it: “GAR-bij kuh-LEK-ter” /ˈɡɑːrbɪdʒ kəˈlɛktər/
Frees memory reference counting misses, like objects pointing only at each other.
What is the garbage collector?
The garbage collector frees memory that reference counting misses, such as two objects that point only at each other and are otherwise forgotten.
import gc
class Node:
pass
a, b = Node(), Node()
a.partner, b.partner = b, a # they point at each other
del a, b
print(gc.collect()) # frees them, returns how many it cleaned up
Level: Master · More Python terms at this level
Updated