c# - View/Diagnose logical .NET threads in memory dump using Visual Studio debugger -
c# - View/Diagnose logical .NET threads in memory dump using Visual Studio debugger -
i have service reporting big amount of logical threads. perfmon:
.net clr locksandthreads -> # of current logical threads: 663 .net clr locksandthreads -> # of current physical threads: 659 process -> thread count: 15
this high, captured memory dump (via sysinternals procdump.exe) , opened visual studio (debug mixed). 1 time loaded up, looked in threads window, , shows 15 os threads, not .net physical or .net logical. service windows service hosts 4 wcf services (system.servicemodel.servicehost).
how find out these threads are, can prepare code , rid of them? how logical threads recognized , displayed visual studio? problem visual studio, or problem dump itself?
first, need obtain memory dump. there variety of methods this. easiest 1 i've found procdump.exe, part of sysinternals, available documentation here.
next, need download , install windbg , sos working (sos module let's view .net managed processes). more info on setting available here. if got dump server (as case), .net versions might off, , sos won't able work correctly dump file. if happens, you'll need re-create few relevant files source .net version windbg installation per this comment.
once setup , have dump loaded, run command:
!threads
this should give list of .net logical threads. of note before list of threads, give summary. of importance question, deadthread extremely high (600+). indicates threads have completed, memory holding (the stack) can't released.
in specific case, found threads getting hung threads wcf thread pool couldn't gc because other threads holding references it. changed other threads null out parent thread when didn't need anymore, , , allowed gc'd correctly.
c# .net multithreading visual-studio-2010 visual-studio
Comments
Post a Comment