Thread Memory Leak

Peter Hansen peter at engcorp.com
Tue Jun 25 09:47:09 EDT 2002


Skip Montanaro wrote:
> 
>     Marco> while 1:
>     Marco>     listThread = []
> 
>     Marco>     for i in range(50):
>     Marco>         listThread.append( threading.Thread( None, runthread ) )
>     Marco>     for i in listThread:
>     Marco>         i.start()
>     Marco>     for i in listThread:
>     Marco>         i.join()
> 
>     Marco>     pid = os.getpid()
>     Marco>     print "==================================="
>     Marco>     os.system( "ps -o vsize,rss %d" % pid )
> 
> You never remove any thread objects from your listThread list.  It fills up
> with completed threads.

Actually, the list is rebound to a new empty list each pass through the 
while loop...

I can't duplicate the symptoms on my machine (RedHat 7.1, Python 2.0).

-Peter



More information about the Python-list mailing list