title: Is there any way to know the total memory consuming by the current program?
body: <p><strong>Note:</strong> The program is just an example, main questions are just after this.</p>
  
  <p>Suppose, I have a <code>C++</code> program like this:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  using namespace std;
  
  int main()
  {
      vector&lt;int&gt;numbers = {4,5,3,2,5,42};
      cout&lt;&lt;"-------------------\n";
      for (auto x : numbers){
          cout&lt;&lt; &amp;x &lt;&lt;endl;
          x+=10;
      }
  
      cout&lt;&lt;"-------------------\n";
      for (vector&lt;int&gt;::iterator it = numbers.begin(); it!=numbers.end(); it++){
          cout&lt;&lt; &amp;(*it) &lt;&lt;" "&lt;&lt; *it &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>-------------------
  0x28fed4
  0x28fed4
  0x28fed4
  0x28fed4
  0x28fed4
  0x28fed4
  -------------------
  0x3b21a8 4
  0x3b21ac 5
  0x3b21b0 3
  0x3b21b4 2
  0x3b21b8 5
  0x3b21bc 42
  </code></pre>
  
  <p>From the memory addresses and increasing values, it is clear that <code>auto</code> is using the variable <code>x</code> each time which is in a new memory.</p>
  
  <p>Now, I want to know, is there any way to know (built-in function or something like that):</p>
  
  <ul>
  <li>How much memory the program used from the beginning to end of its execution?</li>
  <li>What is the maximum memory it used?</li>
  <li>How much memory currently it is using?</li>
  </ul>
  
  <p>I am using C++ in <em>Code::Blocks 13.12</em> in <em>Windows 8.1</em></p>