OutOfMemoryException, stack size is huge, large number of threads

Posted by Captain Comic on Stack Overflow See other posts from Stack Overflow or by Captain Comic
Published on 2010-03-30T08:05:20Z Indexed on 2010/03/30 8:13 UTC
Read the original article Hit count: 184

Filed under:


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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET