gc and weakref
Control the garbage collector, and hold references that don't keep objects alive.
Advanced
weakref.WeakValueDictionary makes caches that let unused objects be freed; gc.collect() forces a cycle collection.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.