title: Finding memory leaks in DirectX program
body: <p>Background:
  I have a Visual Studio 2013 project, involving DirectX (version 9). The project is an x86 solution. When running it in DirectX debug mode, I can't get rid of all the memory leaks.</p>
  
  <p>Output from Visual Studio debug:</p>
  
  <pre><code>Direct3D9: :====&gt; ENTER: DLLMAIN(6417d9a0): Process Detach 0000350c, tid=0000363c
  Direct3D9: (INFO) :MemFini!
  Direct3D9: (ERROR) :Memory still allocated!  Alloc count = 975
  Direct3D9: (ERROR) :Current Process (pid) = 0000350c
  &lt;Solution name&gt; has triggered a breakpoint.
  The program '[13580] &lt;Solution name&gt;' has exited with code 0 (0x0).
  </code></pre>
  
  <p>From the above I learned that the program has finished with 975 items still allocated and not destroyed or released. That it has triggered a breakpoint is due the setting in DirectX debug ("Break on emory leak").</p>
  
  <p>So before posting actual code, I tried to use the PIX utility Microsoft ships with DirectX. By capturing the same solution I got the result below, which indicates that every object created, has also been destroyed.</p>
  
  <p><a href="https://i.stack.imgur.com/sO8Lg.png" rel="nofollow noreferrer">Screen shot from PIX showing objects</a></p>
  
  <p>So, I am left with a memory leak according to VS2013 but not according to PIX. Any ideas on how to proceed?</p>