High memory usage for a .Net application with lots of handles
<p>I'm doing postmortem analysis on a high memory pressure .net application using WinDbg with a process dump and this process is a Windows service.</p>

<p>I got a feeling that most of this 14GB of this process memory consumption comes from aborted threads thus lots of orphan semaphore/events/mutant etc. But I wasn't able to put all this together and add them up like how much memory it takes for a single semaphore/events/mutant and what kind of WinDbg commands that will be helpful for this kind of situation?</p>

<p><strong>The following is the WinDbg output:</strong></p>

<p><strong>!handle</strong></p>

<pre><code>**Type                      Count**

None                        90
Event                       5550
Section                     41
File                        1166
Directory                   3
Mutant                      160
Semaphore                   4581
Key                         78
Token                       2
Thread                      553
IoCompletion                6
Timer                       1
TpWorkerFactory             3
ALPC Port                   9
WaitCompletionPacket        33
</code></pre>

<p><strong>!address -summary</strong></p>

<pre><code>--- Usage Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal

&lt;unknown&gt;                               471        3`86ea2000 (  14.108 Gb)  92.40%    0.01%
</code></pre>

<p><strong>!threads</strong>(lots of thread listed have ThreadAbortException exceptions)</p>

<pre><code>Lock  
   ID OSID ThreadOBJ           State GC Mode     GC Alloc Context                  Domain           Count Apt Exception

  12    3 33f0 00000017e3c23200 1282b221 Preemptive  0000000000000000:0000000000000000 00000017e3bb3930 1     MTA System.Threading.ThreadAbortException 000000181de5d668
</code></pre>