I was profiling my .net windows service. I was trying to discover OutOfMemoryExce开发者_如何学JAVAption and discovered that my stack size is huge and is growing because the the number of threads keeps growing.
Each thread gets 1024 KB on Windows x64 machine. Thus when my app has 754 threads the stack size would be 772 MB. The problem for me is that i don't know where these thread come from. Initially my app has a very limited number of threads and they keep growing with time.
I have two suspicions - either these threads are created by WCF or by database connection.
My application uses both WCF and datasets. Also I tried to profile my app in Ants do Trace i can see large number of System.ServiceModel.Channels.ClientReliableDuplexSessionChannel
and this number is increasing with time. I can see thousands of these objects created. So what I want to know is who is creating threads (tools to discover, profilers) and if it is WCF who is creating these threads.
UPDATE
I have stopped in debugger my app to look at the threads. All I can see a large number of Win32 threads with call stack like that
ntdll.dll!7c82860c()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!7c827d99()
kernel32.dll!77e4e02f()
mscorwks.dll!79e7c7a8()
mscorwks.dll!79f943fe()
mscorwks.dll!79f94237()
mscorlib.ni.dll!792f5577()
mscorlib.ni.dll!792e01c5()
You could look at the program using a debugger - then you can see what all those threads are doing (most of them probably have a very similar call stack).
精彩评论