[Python-Dev] Does eval() leak?
John.Marshall at ec.gc.ca
Thu Feb 16 17:30:02 CET 2006
Should I expect the virtual memory allocation
to go up if I do the following?
raw = open("data").read()
d = eval(raw)
I would have expected the memory allocated to the
object referenced by d to be deallocated, garbage
collected, and reallocated for the new eval(raw)
results, assigned to d.
The file contains a large, SIMPLE (no self refs; all
native python types/objects) dictionary (>300K).
While doing 'd = eval(raw)' in the python interpreter
I am monitoring the VIRT column of top and it keeps
increasing until I run out of memory.
When I use a safe_eval() from:
I have no memory problems.
I see this under python 2.3.5 (fast and obvious).
More information about the Python-Dev