Thread Memory Leak

Skip Montanaro skip at
Tue Jun 25 09:11:08 EDT 2002

    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.

Skip Montanaro
skip at

More information about the Python-list mailing list