title: How to clear vector in C++ from memory
body: <p>I'm new to C++ so this may be a newbie question however I'm not entirely clear how to clear it from memory. I've searched online and looked are several answers but was unclear on how to properly execute what im trying to do.</p>
  
  <p>How can i clear my vector from memory correctly in c++? Thanks and i apologize if this is a dup post.</p>
  
  <pre><code>vector&lt;ElementData&gt; Elements;
  </code></pre>
  
  <p>As mentioned by a comment below, i would like to return the memory used as well.</p>
  
  <blockquote>
    <p>except that it will not return any memory to the system as the
    capacity remains unchanged.</p>
  </blockquote>