title: What is the best solution to replace a new memory allocator in an existing code?
body: <p>During the last few days I've gained some information about memory allocators other than the standard <code>malloc()</code>. There are some implementations that seem to be much better than <code>malloc()</code> for applications with many threads. For example it seems that <code>tcmalloc</code> and <code>ptmalloc</code> have better performance.</p>
  
  <p>I have a C++ application that uses both <code>malloc</code> and <code>new</code> operators in many places. I thought replacing them with something like <code>ptmalloc</code> may improve its performance. But I wonder how does the <code>new</code> operator act when used in C++ application that runs on Linux? Does it use the standard behavior of <code>malloc</code> or something else?</p>
  
  <p>What is the best way to replace the <code>new</code> memory allocator with the old one in the code? Is there any way to override the behavior or <code>new</code> and <code>malloc</code> or do I need to replace all the calls to them one by one?</p>