views:

101

answers:

2

Hello,

In previous series:

http://stackoverflow.com/questions/2543648/outofmemoryexception-stack-size-is-huge-large-number-of-threads

I have a .net windows service that consumes a lot of memory. The GC heap is not big. Also the stack size is not big. What is big is something called a private data. Also I can see in task manager that my application consumes a lot something that taskmanager calls a handle. My application consumes 2326 handles. I believe that these handles are some windows handles that occupy private data. I can see that this private data is occupied by blocks marked as Thread Environment Block. What is that?

Screenshot of my application memory usage by VMMap

Screenshot of my application memory usage by Task Manager

UPDATE

I run ProcessExplorer. I have two instances of my service running at the moment. I can see that they consume a lot of virtual memory for Gen2 GC. This look suspicios. Also total reserved for GC Heap size is the same for two processes.

alt text

+1  A: 

Yes, quite a resource hog. I'm guessing at variables you've marked with the [ThreadStatic] attribute. You've got way too many threads.

Hans Passant
+2  A: 

It seems that you have classic memory leak, when newly created objects can not be collected because they are referenced from a garbage collection roots.

The most effective way to get rid of such problem - use WinDBG + SOS and !gcroot command. Example of memory leak bug investigation can be found here: http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx

Good luck!

Yauheni Sivukha
No, he'd see a large GC heap.
Hans Passant