当前位置: 动力学知识库 > 问答 > 编程问答 >

Leaking "Thread-n" strings in python

问题描述:

I am trying to debug a memory leak in a python 2.4 ThreadingUnixStreamServer based application.

It appears that I am leaking memory on every request to the server.

Trying to debug it, I used the gc module to count the number of objects between consecutive calls to "handle", and received the same number.

However, when I checked the number of strings, I noticed that it grew between requests.

When I diffed the list of strings between calls, I noticed that I had a new string created "Thread-n" (where "n" is a running number, e.g. "Thread-3", "Thread-4", etc.).

I assume this has something to do with the fact that the server spawns a new thread with a new name for each request, but it is not clear to me why the old names were not cleaned from memory. I have checked and seen that there is no increase in the number of concurrent threads, so it does not appear as if I am leaking actual threads.

Any idea how I can find the references to these strings, or, alternatively, any guesses on what may cause this leak, or how I can investigate it?

Thanks.

分享给朋友:
您可能感兴趣的文章:
随机阅读: