I was wondering which is the default memory allocator in G++ 4.4.1, on Ubuntu 9.1. I am interested in comparing different C++ allocators in a multithreaded environment. And where can I get more information about the default memory allocator?
EDIT: I refer to new and delete operators. The only linking is to rt and pthread
Regards
The g++ new operator is indeed implemented using glibc malloc.
Memory allocation itself is then performed using the standard unix system call mmap.
You can get more information about your memory allocator using mallinfo.
See Statistics-of-Malloc and Efficiency-and-Malloc for more information.
G++ will create references to operator new() in libstdc++ that comes with G++. That in turn uses the malloc() defined in the libc that is installed on your system (usually glibc).
Most replacement allocators will point one of them to their implementation, usually they just replace malloc(). For example, you can use Google's TC Malloc by simply preloading their shared library. No changes to the compiled application necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With