Python threads and memory usage

Mike mszpadzik at gmail.com
Thu May 29 15:01:30 EDT 2008


Hi,

I'm writing client-server application in Python. It's monitoring
system, where server listen and waits for TCP connections, and every
connection takes own thread. Every thread puts data from clients to
Queue and exits. Then there is one DB loader thread, which loads all
data from Queue to MySQL DB.

I observed, that every thread reserved some memory, and after exit
thread doesn't freed it. When i leaved my server working for 3 days,
then it takes 15% of 512MB memory (during that time about 15000
threads were created and stopped). When server starts it only takes
about 1% of memory.

I know that I can made client which connects once and keep this
session with server thread all time (it should resolve my problems),
but I'm curious if this is normal or it is something like memory leak.
Or maybe I'm doing something wrong :)

If You need I can paste all my code.

Regards



More information about the Python-list mailing list