title: c++ thread can not reuse deallocated memory that allocated by main
body: <p>I have a problem when create new object by main thread and then delete it, after that I create it again using the same function by Thread and found that my memory(monitor from htop) grow up. Am I wrong on this code or this is its behavior?</p>
  
  <pre><code>void createAndDeleteObj()
  {
      std::vector&lt;SomeObj *&gt; objVector;
  
      //   create object
      for( size_t i = 0; i &lt; 1000000; ++i )
      {
          objVector.emplace_back( new SomeObj() );
      }
  
      //   delete object
      for( size_t i = 0; i &lt; 1000000; ++i )
      {
          delete objVector[i];
      }
  }
  
  void main()
  {
  
       createAndDeleteObj();
  
       //  memory not increase
       createAndDeleteObj();
  
       // memory increase equal to the first time used
       Thread thread1( createAndDeleteObj );
  
       thread1.join();
  
       // call this function by thread again, memory not increase 
       Thread thread2( createAndDeleteObj );
  
       thread2.join();
  
       //  memory not increase
       createAndDeleteObj();
  }
  </code></pre>
  
  <p>Since the concept of Thread share the heap space, i dont know why it always allocate new memory for Thread, why it does not use memory allocated by main even if it is freed.</p>