Apparent eval() leak for python 2.3.5

J

John Marshall

Hi,

I am reposting this message from python-dev.

Could someone please test the code below
to verify that there is indeed a problem
with eval() under python 2.3.5. I have
rebuilt python 2.3.5 under the latest debian
and under RH 7.3 (in case the problem is
in system libraries).

The following code causes the virtual memory
allocation to constantly increase until there
is no more memory left (the VIRT column of the
'top' utility display).

-----
#! /usr/bin/env python
#
# evalleak.py

def builddict():
d = {}
for i in xrange(10000):
d = { "int": 0, "str": "nada", "dict": {} }
return d

if __name__ == "__main__":
d = builddict()
st = str(d)
print "len(st): %d" % len(st)
while 1:
d = eval(st)
 
B

Benjamin Niemann

John said:
Hi,

I am reposting this message from python-dev.

Could someone please test the code below
to verify that there is indeed a problem
with eval() under python 2.3.5. I have
rebuilt python 2.3.5 under the latest debian
and under RH 7.3 (in case the problem is
in system libraries).

The following code causes the virtual memory
allocation to constantly increase until there
is no more memory left (the VIRT column of the
'top' utility display).

I have this leak, too in python2.3 under debian/sid:
Python 2.3.5 (#2, Nov 20 2005, 16:40:39)
[GCC 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)] on linux2

python2.4 seems to be unaffected.
Python 2.4.2 (#2, Nov 20 2005, 17:04:48)
[GCC 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)] on linux2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,284
Messages
2,571,414
Members
48,106
Latest member
JamisonDev

Latest Threads

Top