Problem Statement
Does using 'del' free memory immediately? How do you diagnose leaks?
Explanation
del only deletes a name binding. If other references still exist, the object stays alive. When the last reference goes away, CPython frees it, or the cycle collector reclaims it later if part of a cycle.
To diagnose leaks, track object counts over time with tracemalloc or objgraph like tools. Look for growing containers, cache keys that never expire, or reference cycles involving long lived objects.
Code Solution
SolutionRead Only
import tracemalloc tracemalloc.start() # run workload print(tracemalloc.get_traced_memory())
