OutOfMemoryException, stack size is huge, large number of threads
- by Captain Comic
Hello,
I was profiling my .net windows service.
I was trying to discover OutOfMemoryException 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.