memory leak?

Trevor Perrin trevp at trevp.net
Sun Aug 3 14:35:18 EDT 2003


"Bjorn Pettersen" <BPettersen at NAREX.com> wrote in message news:<mailman.1059908345.3987.python-list at python.org>...
> > From: Trevor Perrin [mailto:trevp at trevp.net] 
> > 
> > Every time I run the below function from the interpreter, python.exe's
> > memory usage increases by 5 Megs and stays at this higher level
> > (python 2.3b2 on WinXP).  I tried to isolate this to something
> > simpler, but wasn't successful.
> > 
> > Is this a memory leak, or is there another explanation?
> [...]

Hi Bjorn,

> 
> Have your tried 2.3 final,

I just did, same thing.


> how are you determining there is a memory
> leak (which tools),

Windows Task Manager display process memory use.


> what steps did you take that weren't successful, 

I tried calling array.array() and random.randrange() the same number
of times in a loop, but the behavior didn't reproduce.


> did
> you try without using "import *", how about loading it as a module and
> then deleting the module (i.e. have you inadvertenly created an object
> that is still live)?

I tried that, and also using xrange().  Below is a transcript from the
interpreter, after running it python.exe had increased memory use from
~3 MB to ~21 MB.  Maybe there's an innocuous explanation, I'm no
python expert, I'm just curious:

>>> import array
>>> import random
>>> def test():
...   for x in xrange(10000):
...     b = array.array("B", [random.randrange(0,256) for count in
range(64)])
>>> test()
>>> test()
>>> test()
>>> test()
>>> del(array)
>>> del(random)

Trevor




More information about the Python-list mailing list