Leaking threads
Leaking threads
Hello,
I have an issue where my application seems to leak threads. I log the managed thread id on each request and as the application keeps running the ids increase (up to a point where the app stops responding). I've run .NET Memory Profiler 5 and I don't see any obvious memory leaks, but my question if there is an option in .NET Memory Profiler to trace threads and where they are created, etc?
Thanks,
/Hakan
I have an issue where my application seems to leak threads. I log the managed thread id on each request and as the application keeps running the ids increase (up to a point where the app stops responding). I've run .NET Memory Profiler 5 and I don't see any obvious memory leaks, but my question if there is an option in .NET Memory Profiler to trace threads and where they are created, etc?
Thanks,
/Hakan
-
- Posts: 1030
- Joined: Wed Mar 02, 2005 7:53 pm
Re: Leaking threads
If there is a thread leak, you should be able to see an increasing amount System.Threading.Thread instances when you collect snapshots. If there's a native thread look, you can enable the unmanaged resources tracker and investigate the Kernel-Thread (HANDLE) resource.
Are you seeing increasing number of threads when you collect several snapshots?
Are you seeing increasing number of threads when you collect several snapshots?
Best regards,
Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
SciTech Software AB
Re: Leaking threads
Thanks for your reply. I'm not seeing any increased managed or unmanaged threads, so it must be something else then. But isn't it "odd" that the managed thread id keeps increasing? I have another project where I pump 1000s of messages through and the thread ids are always reused.
-
- Posts: 1030
- Joined: Wed Mar 02, 2005 7:53 pm
Re: Leaking threads
How are you retrieving the thread id?
There's a risk that the unmanaged resources tracker fails to identify all threads, for instance if thread handles are duplicated. Have you investigated how many threads the process has using the Task manager or Process explorer?
There's a risk that the unmanaged resources tracker fails to identify all threads, for instance if thread handles are duplicated. Have you investigated how many threads the process has using the Task manager or Process explorer?
Best regards,
Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
SciTech Software AB
Re: Leaking threads
Just using Thread.ManagedThreadId.
I checked Task Manager too and the thread count that is consistent with the thread count in the app, so I think I'm going down the wrong path. Thanks for your help!
I checked Task Manager too and the thread count that is consistent with the thread count in the app, so I think I'm going down the wrong path. Thanks for your help!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 17 guests