title: How to really delete vectors
body: <p>I am quite new to C++ memory management because unlike C, there are more hurdles to freeing all memory.</p>
  
  <p>I am trying to successfully delete a pointer to vector of any type (i.e. vector  * data)</p>
  
  <pre><code>/** 
   * We test the program in accessing vectors
   * with dynamic storage
  **/
  #include &lt;iostream&gt;
  #include &lt;vector&gt; // you must include this to use vectors
  
  using namespace std;
  
  int main (void){
      // Now let's test the program with new and delete
      // for no memory leaks with vectors (type safe)
      // however, just calling delete is not enough to free all memory
      // at runtime
      vector &lt;int&gt; * test_vect = new vector &lt;int&gt; (10,5);
  
      // Print out its size
      cout &lt;&lt; "The size of the vector is " &lt;&lt; test_vect-&gt;size()
           &lt;&lt; " elements" &lt;&lt; endl;
  
      // run through vector and display each element within boundary
      for (long i = 0; i &lt; (long)test_vect-&gt;size(); ++i){
          cout &lt;&lt; "Element " &lt;&lt; i &lt;&lt; ": " &lt;&lt; test_vect-&gt;at(i) &lt;&lt; endl;
      }
  
      delete test_vect;
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>However, I get a memory leak after using valgrind</p>
  
  <pre><code>==2301== HEAP SUMMARY:
  ==2301==     in use at exit: 4,184 bytes in 2 blocks
  ==2301==   total heap usage: 4 allocs, 2 frees, 4,248 bytes allocated
  ==2301== 
  ==2301== LEAK SUMMARY:
  ==2301==    definitely lost: 0 bytes in 0 blocks
  ==2301==    indirectly lost: 0 bytes in 0 blocks
  ==2301==      possibly lost: 0 bytes in 0 blocks
  ==2301==    still reachable: 4,096 bytes in 1 blocks
  ==2301==         suppressed: 88 bytes in 1 blocks
  </code></pre>
  
  <p>How can I be able to get rid of all traces of memory leaks with pointer to vector (i.e. at runtime)?</p>