A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-February/061149.html below:

[Python-Dev] Does eval() leak?

[Python-Dev] Does eval() leak? [Python-Dev] Does eval() leak?John Marshall John.Marshall at ec.gc.ca
Thu Feb 16 17:30:02 CET 2006
Hi,

Should I expect the virtual memory allocation
to go up if I do the following?
-----
raw = open("data").read()
while True:
	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:
     http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469
I have no memory problems.

I see this under python 2.3.5 (fast and obvious).

Thanks,
John

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4