title: Does deleting an unordered_map element also release the malloc memory assigned to that unordered_map element?
body: <p>Does deleting an unordered_map element also release the malloc memory assigned to that unordered_map element. I was under the impression it does not. Please see the difference in two scenarios.</p>
  <pre><code>struct sdata{
      unsigned pid;
      unsigned long start;
      unsigned long end;
  };
  
  
  int main(){
      std::unordered_map&lt;unsigned,struct sdata*&gt; ht;
      ht[0] = (struct sdata*)malloc(sizeof(struct sdata));
      ht[1] = (struct sdata*)malloc(sizeof(struct sdata));
      ht[2] = (struct sdata*)malloc(sizeof(struct sdata));
      for (int i=0; i&lt; 3; i++){
           ht[i]-&gt;start = i;
           ht[i]-&gt;end = i+1;
      }
      struct sdata *temp = ht[1];
      delete ht[1];
      //temp-&gt;start = 100;
      std::cout&lt;&lt;&quot;start: &quot;&lt;&lt;temp-&gt;start&lt;&lt;std::endl;
      std::cout&lt;&lt;&quot;end: &quot;&lt;&lt;temp-&gt;end&lt;&lt;std::endl;
      return 0;
  }
  </code></pre>
  <p>After delete ht[1], temp-&gt;start printed a garbage value, and obvious removing the delete values printed are correct.</p>
  <p>And surprisingly, after delete, if I access the temp-&gt;start by assigning 100 to it
  (commented line in code), the value printed by temp-&gt;start is correct.</p>
  <p>Can anyone please help me to understand this behavior of <strong>unordered_map</strong>
  Thanks in advance,</p>