jemalloc 是 Facebook 推出的一种通用 malloc 实现,在 FreeBSD、firefox 中被广泛使用。比起 ptmalloc2 具有更高的性能。
Copy wget https://github.com/jemalloc/jemalloc/releases/download/5.0.1/jemalloc-5.0.1.tar.bz2
tar -xjvf jemalloc-5.0.1.tar.bz2
cd jemalloc-5.0.1
./configure --prefix=/usr/local/jemalloc --enable-debug
make -j4 && sudo make install
Copy # echo /usr/local/jemalloc/ >> /etc/ld.so.conf.d/jemalloc.conf
# ldconfig
Copy $ gcc -L/usr/local/jemalloc/lib -Wl,--rpath=/usr/local/jemalloc/lib -ljemalloc test.c
$ ldd a.out
linux-vdso.so.1 (0x00007fff69b62000)
libjemalloc.so.2 => /usr/local/jemalloc/lib/libjemalloc.so.2 (0x00007f744483b000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f744447f000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f74440ea000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f7443d61000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f7443b43000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f744393f000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f7443727000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f7444f02000)