c++ memory managment problem, std::vector nevere relase memory out of scope : <p>i am very confuse about this simple code.
why this code can release memory that allocated.</p>

<pre><code>double *a;
for(int i = 0 ; i &lt; 1000000 ; i++)
{
    if(1){
        a = new double ;
    }
    if(1){
        delete a;
    }
}
</code></pre>

<p>but this code can not remove all memory that allocated.</p>

<pre><code>std::vector&lt;double *&gt;rubberList ;
for(int i = 0 ; i &lt; 1000000 ; i++)
{
    rubberList.push_back(new double);
    //delete rubberList[i];
}
for(unsigned long j = 0 ; j &lt; 1000000 ; j++)
{
            delete rubberList.at(j);
}
</code></pre>

<p>and when delete items in allocator block correctly remove memory.</p>

<pre><code>for(int i = 0 ; i &lt; 1000000 ; i++)
{
    rubberList.push_back(new double);
    delete rubberList[i];
}
</code></pre>

<p>tnx</p>
