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