[Python-Dev] Does eval() leak?

2006-02-17 Thread John Marshall
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

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Does eval() leak?

2006-02-20 Thread John Marshall
Martin v. Löwis wrote:
> John Marshall wrote:
> 
>>Should I expect the virtual memory allocation
>>to go up if I do the following?
> 
> 
> python-dev is a list for discussing development of Python,
> not the development with Python. Please post this question
> to [EMAIL PROTECTED]
> 
> For python-dev, a message explaining where the memory leak
> is and how to correct it would be more appropriate. Most
> likely, there is no memory leak in eval.

My question was not a "development with Python" question.
However, I posted to python-list as you said. Only one
person responded to a request to test the provided code (~10
lines) which demonstrates a problem with eval()--he
confirmed my observations. As the problem _does exist_ for
2.3.5 which is the last 2.3 version still available at
python.org, I would suggest people avoid using it if they
do eval()s.

Unfortunately I, myself, cannot check into it more.

John
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com