title: Finding memory leak
body: <p>I have a web application that I wrote using a lot of different 3rd party components, a CMS and of course my code. For some reason I get out of memory exception.</p>
  
  <blockquote>
    <p>Script threw an exception: Out of memory</p>
  </blockquote>
  
  <p>I tried to find out what is going on. This is what I've found:</p>
  
  <ul>
  <li><p>I ran the test with 50 threads to call 15 pages of my web-application. Memory seems fine. The IIS process is using only 400 MB of RAM</p></li>
  <li><p>I've added a space in web.config and suddenly my IIS process started to grow to more than a GB in 30 minutes.
  Visual studio could not take snapshot of my memory since it is too big (really?!) So I've installed ANTS memory profiler but it says that my application is using only around 300 MB<a href="https://i.stack.imgur.com/X7aDO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/X7aDO.png" alt="ANTS only 300 MB"></a></p></li>
  </ul>
  
  <p>IIS process takes 1 GB
    <a href="https://i.stack.imgur.com/ldk8c.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ldk8c.png" alt="[1]: https://i.stack.imgur.com/Ig8"></a>pY.png</p>
  
  <p>I stopped the test after some minutes but the memory has not released.</p>
  
  <p>(ANTS profiler stopped working so I've restarted it)
  <a href="https://i.stack.imgur.com/mX58O.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mX58O.png" alt="422MB after release"></a>
  <a href="https://i.stack.imgur.com/iUXkm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iUXkm.png" alt="IIS 1.2GB"></a>
  <a href="https://i.stack.imgur.com/uf1EF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uf1EF.png" alt="Summary"></a>
  <a href="https://i.stack.imgur.com/eMeFK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/eMeFK.png" alt="4MB of strings"></a></p>
  
  <p>It doesn't seem like the application is using 100-200MB memory specially that I am using output caching for my controllers. What I don't understand is why memory consumed by IIS is growing all the time  and what is wrong </p>
  
  <h2>Update</h2>
  
  <p>My application has been restarted automatically with a crash in W3WP causing IIS to release the memory while my stress was not running for a while:</p>
  
  <blockquote>
    <p>Application: w3wp.exe
    Framework Version: v4.0.30319
    Description: The process was terminated due to an internal error in the .NET Runtime at IP 5A3A86F1 (5A0F0000) with exit code 80131506.</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>Faulting application name: w3wp.exe, version: 10.0.15063.0, time stamp: 0xacce422f
    Faulting module name: clr.dll, version: 4.7.2098.0, time stamp: 0x59028d36
    Exception code: 0xc0000005
    Fault offset: 0x002b86f1
    Faulting process id: 0x50a4
    Faulting application start time: 0x01d2ee688f323893
    Faulting application path: C:\WINDOWS\SysWOW64\inetsrv\w3wp.exe
    Faulting module path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
    Report Id: 4362ddc5-f8d7-4441-8916-3830f9268b3a
    Faulting package full name: 
    Faulting package-relative application ID: </p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/UvZCz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UvZCz.png" alt="enter image description here"></a></p>
  
  <h2>Update 2</h2>
  
  <p>I ran DebugDiag and I've stress tested the site until it consumed around 3.5 GB of my RAM.</p>
  
  <p><a href="https://i.stack.imgur.com/cGjzY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cGjzY.png" alt="enter image description here"></a></p>
  
  <p>And Chakra is a Microsoft's library. </p>
  
  <p><a href="https://i.stack.imgur.com/l0wZB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/l0wZB.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/m3wKD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/m3wKD.png" alt="enter image description here"></a></p>
  
  <p>So now I have 2 questions.</p>
  
  <ol>
  <li>Is it the ChakraCore that has leak or is it the one that is using/allocating it? How to define which library?</li>
  </ol>
  
  <p>2- It says 27,000 allocations. Does it mean that there are still 27,000 in the memory or some of them might be allocated and then disposed?</p>
  
  <p>3- It still doesn't tell me anything about the rest of 3GB of consumed RAM. it i only 600 MB in total (private+virtual).</p>