Leaking threads

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.

Moderator: SciTech Software

Leaking threads

Postby HakanL » Wed Apr 15, 2015 7:36 am

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
HakanL
 
Posts: 3
Joined: Wed Apr 15, 2015 7:26 am

Re: Leaking threads

Postby Andreas Suurkuusk » Wed Apr 15, 2015 12:45 pm

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?
Best regards,

Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
 
Posts: 963
Joined: Wed Mar 02, 2005 7:53 pm
Location: Sweden

Re: Leaking threads

Postby HakanL » Wed Apr 15, 2015 5:46 pm

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.
HakanL
 
Posts: 3
Joined: Wed Apr 15, 2015 7:26 am

Re: Leaking threads

Postby Andreas Suurkuusk » Thu Apr 16, 2015 4:37 pm

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?
Best regards,

Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
 
Posts: 963
Joined: Wed Mar 02, 2005 7:53 pm
Location: Sweden

Re: Leaking threads

Postby HakanL » Thu Apr 16, 2015 5:03 pm

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!
HakanL
 
Posts: 3
Joined: Wed Apr 15, 2015 7:26 am


Return to Using .NET Memory Profiler

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 3 guests

SciTech Software logo

© Copyright 2001-2016. SciTech Software AB
All rights reserved.


SciTech Software AB
Kartvägen 21
SE-175 46 Järfälla
Sweden


E-mail: mail@scitech.se

Telephone: +46-706868081

cron