Ptmalloc is the memory allocation management of glibc
Tcmalloc is Google's Memory Allocation Management Module
Jemalloc is the memory allocation management provided by BSD.
The performance comparison between the three is shown in the figure below:
I tested it myself:
The Code is as follows:
1: #include <iostream>
2: #include <map>
3:
4: using namespace std;
5: int main(int argc, char**argv) {
6: cout << "Hello world" << endl;
7: std::map<int,int> int_map;
8: for (int i = 0; i < 10000000; ++i) {
9: int_map.insert(std::map<int,int>::value_type(i,i));
10: }
11: return 0;
12: }
A map insert operation is performed times.
For the convenience of testing, we have generated three binary files that are linked to libraries using jemalloc, tcmalloc, and ptmalloc for comparison:
LDD jemalloc_test
Linux-vdso.so.1 = & gt; (0x00007fffc6fc3000)
Libjemalloc. so.1 =>/usr/local/lib/libjemalloc. so.1 (0x00007f45181aa000)
Libstdc ++. so.6 =>/usr/lib/x86_64-linux-gnu/libstdc ++. so.6 (0x00007f4517ea4000)
Libm. so.6 =>/lib/x86_64-linux-gnu/libm. so.6 (0x00007f4517c1e000)
Libgcc_s.so.1 =>/lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f4517a08000)
Libc. so.6 =>/lib/x86_64-linux-gnu/libc. so.6 (0x00007f4517673000)
Libpthread. so.0 =>/lib/x86_64-linux-gnu/libpthread. so.0 (0x00007f4517454000)
Libdl. so.2 =>/lib/x86_64-linux-gnu/libdl. so.2 (0x00007f4517250000)
/Lib64/ld-linux-x86-64.so.2 (0x00007f45183f2000)
LDD tcmalloc_test
Linux-vdso.so.1 => (0x00007fff94160000)
Libtcmalloc. so.0 =>/usr/lib/libtcmalloc. so.0 (0x00007f20107dc000)
Libstdc ++. so.6 =>/usr/lib/x86_64-linux-gnu/libstdc ++. so.6 (0x00007f20104d6000)
Libm. so.6 =>/lib/x86_64-linux-gnu/libm. so.6 (0x00007f2010250000)
Libgcc_s.so.1 =>/lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f201003a000)
Libc. so.6 =>/lib/x86_64-linux-gnu/libc. so.6 (0x00007f200fca5000)
Libunwind. so.7 =>/usr/lib/libunwind. so.7 (0x00007f200fa8b000)
/Lib64/ld-linux-x86-64.so.2 (0x00007f2010a68000)
LDD ptmalloc_test
Linux-vdso.so.1 => (0x00007fff08501000)
Libstdc ++. so.6 =>/usr/lib/x86_64-linux-gnu/libstdc ++. so.6 (0x00007f7e6c156000)
Libm. so.6 =>/lib/x86_64-linux-gnu/libm. so.6 (0x00007f7e6bed1000)
Libgcc_s.so.1 =>/lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7e6bcba000)
Libc. so.6 =>/lib/x86_64-linux-gnu/libc. so.6 (0x00007f7e6b925000)
/Lib64/ld-linux-x86-64.so.2 (0x00007f7e6c483000)
Then execute each program separately. The time used for statistics is as follows:
Time./jemalloc_test
Hello World
Real 0m9. 927 s
User 0m9. 650 S
Sys 0m0. 250 s
Time./tcmalloc_test
Hello World
Real 0m9. 836 s
User 0m9. 410 s
Sys 0m0. 410 s
Time./ptmalloc_test
Hello World
Real 0m11. 890 s
User 0m11. 520 s
Sys 0m0. 360 s
The performance of jemalloc and tcmalloc is different, while that of ptmalloc is lower.
Here is a brief introduction to performance. Later I will take the time to introduce their respective implementation principles.
Refer: http://blog.csdn.net/yfkiss/article/details/7035579