title: Task Manager disagrees with Process Explorer?
body: <p>I'm trying to track down a memory leak in my .NET app. Windows Task Manager reports that the memory usage stays constant, while <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653" rel="noreferrer">Process Explorer</a> reports that the memory usage is raising.</p>
  
  <p>In Task Manager, I'm looking in the only memory column, "Memory (Private working set)". In Process Explorer I'm looking in the "Private bytes" column because it's raising and the value under "Working set" isn't.</p>
  
  <p>Now, certainly Process Explorer is the right one because after several allocations, my app crashes with an <em>Out of memory</em> exception. The question is, <strong>why does Task Manager misreport the memory usage of the app</strong>? Not only that, but it also misreports the global system free memory (the graph in the Performance tab stays constant).</p>
  
  <p><strong>My code shouldn't be needed, but here it is for completeness.</strong> It shows an empty window that holds a big array. When any key is pressed, the window is closed and a new one is opened, holding a new array. The old window has leaked, probably due to a bug in the qt4dotnet GUI library.</p>
  
  <pre><code>using System;
  using com.trolltech.qt.gui;
  
  namespace LeakTest
  {
      class Test : QWidget
      {
          public byte[] Data = new byte[1000 * 1000 * 100];
  
          public Test()
          {
              show();
              GC.Collect(); // so measurements are more accurate
          }
  
          protected override void keyPressEvent(QKeyEvent arg__1)
          {
              disposeLater();
              new Test();
          }
  
          [STAThread]
          static void Main(string[] args)
          {
              QApplication.initialize(args);
  
              new Test();
  
              QApplication.exec();
          }
      }
  }
  </code></pre>
  
  <p>OS: Windows 7</p>
  
  <p><em>Interesting note:</em> when I make "Data" a 2D jagged array of dimensions <code>[1000 * 1000 * 100][1]</code>, Task Manager <em>does</em> report raising memory usage.</p>