title: Why does a Process's "Private Bytes" memory counter never return back to it's original value?
body: <p>If I have a native C++ program and look at it's initial "Private bytes" memory counter why would it not go back down to it's original value after an object has been created and then deleted?</p>
  
  <p>For example if I have an application (32bit, Native C++ MFC  ) that has two buttons.
  One in a loop that allocates 1,000,000 instances of an object and then  the other button that other then deletes those same objects.  </p>
  
  <p>If I look at my Private bytes counters for the process I have the following 3 values:<br>
  .<br>
  Description..........    Private Bytes Count<br>
  =============  ======================<br>
  App Started.................1,608K<br>
  Objects. created........33,176K<br>
  Objects. deleted..........2,520K  </p>
  
  <p>Leak of 912K ( 2520-1608 ) ?</p>
  
  <p>Assuming that my code does not leak memory which I believe it is not why does the Private bytes count not go back to the <strong>EXACT</strong> initial value?</p>
  
  <p>If I click on the two buttons again ( not having restarted the program ) ( 1st button creates another 1,000,000 objects ) and the second deletes them I have this:</p>
  
  <p>Objects. created........33,472K<br>
  Objects. deleted..........2,552K  </p>
  
  <p>New Leak of ( 2552-2520 ) = 32K  </p>
  
  <p>I am just looking for an explanation on why the memory would not go back to the orginal value.</p>
  
  <p>Sample Code ( some generated code stripped out to reduce noise ):</p>
  
  <pre><code>class Person
  {
  public:
     Person(void);
     ~Person(void);
  
     Person* Next;
     int A;
     int B;
     int C;
     int D;
  
  };
  
  
  class Cdelme_MFC2005_MemoryTestDlg : public CDialog
  {
  // some code stripped out here to simplify reading.
  
     Person* m_PeopleList_First;
     Person* m_PeopleList_Last;
  
  public:
     afx_msg void OnBnClickedButtonAllocate();
     afx_msg void OnBnClickedButtonFree();
  };
  
  
  Cdelme_MFC2005_MemoryTestDlg::Cdelme_MFC2005_MemoryTestDlg(CWnd* pParent /*=NULL*/)
      : CDialog(Cdelme_MFC2005_MemoryTestDlg::IDD, pParent)
  {
      m_hIcon = AfxGetApp()-&gt;LoadIcon(IDR_MAINFRAME);
  
     m_PeopleList_First = NULL;
     m_PeopleList_Last = NULL;
  
  }
  
  
  void Cdelme_MFC2005_MemoryTestDlg::OnBnClickedButtonAllocate()
  {
     if ( m_PeopleList_First == NULL )
     {
        m_PeopleList_First = new  Person();
        m_PeopleList_First-&gt;A = 0;
        m_PeopleList_Last = m_PeopleList_First;
     }
  
     int MAX = 1000000;
     for (int i = 0; i &lt;MAX ; i++)
     {
        Person* p = new Person();
        p-&gt;A = i;
        m_PeopleList_Last-&gt;Next = p;
        m_PeopleList_Last = p;
     }
  }
  
  void Cdelme_MFC2005_MemoryTestDlg::OnBnClickedButtonFree()
  {
     Person* p = m_PeopleList_First;
     while ( p != NULL )
     {
        Person* pNext = p-&gt;Next;
        delete p;
        p = pNext;
     }
     m_PeopleList_First = NULL;
     m_PeopleList_Last = NULL;
  }
  </code></pre>