JEMalloc은 기본적으로 yum 으로 설치가 가능하지만, 최신 JEMalloc을 사용하려면 소스를 직접 받아다가 컴파일을 하는것이 좋다.
JEMalloc 소스는 다음의 url에서 확인할 수 있다.
https://github.com/jemalloc/jemalloc
현재 여기에서 제공되는 최신 본은 Ver. 4.0.4 이다. 테스트 목적이나 개발 목적이 아니라면 Branch를 master로 선택하여 다운받으면 된다.
그러면, jemalloc-master.zip 파일을 받을 수 있다.
unzip으로 압축을 풀면 다음과 같은 디렉토리가 생성된다.
[root@test minstall]# ls
jemalloc-master jemalloc-master.zip
jemalloc-master로 들어가서 autogen.sh 를 실행하도록 한다.
[root@test minstall]# cd jemalloc-master
[root@test jemalloc-master]# ls
autogen.sh ChangeLog config.stamp.in configure.ac coverage.sh include install-sh Makefile.in src
bin config.guess config.sub COPYING doc INSTALL jemalloc.pc.in README test
[root@test jemalloc-master]# ./autogen.sh
autoconf
./configure --enable-autogen
checking for xsltproc... /usr/bin/xsltproc
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
.....
정상적으로 실행 되었으면 make 를 실행한다.
[root@test jemalloc-master]# make
gcc -std=gnu99 -Wall -Werror=declaration-after-statement -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -fPIC -DPIC -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/jemalloc.pic.o src/jemalloc.c
gcc -std=gnu99 -Wall -Werror=declaration-after-statement -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -fPIC -DPIC -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/arena.pic.o src/arena.c
gcc -std=gnu99 -Wall -Werror=declaration-after-statement -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -fPIC -DPIC -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/atomic.pic.o src/atomic.c
gcc -std=gnu99 -Wall -Werror=declaration-after-statement -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -fPIC -DPIC -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/base.pic.o src/base.c
gcc -std=gnu99 -Wall -Werror=declaration-after-statement -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -fPIC -DPIC -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/bitmap.pic.o src/bitmap.c
gcc -std=gnu99 -Wall -Werror=declaration-after-statement -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -fPIC -DPIC -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk.pic.o src/chunk.c
gcc -std=gnu99 -Wall -Werror=declaration-after-statement -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -fPIC -DPIC -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_dss.pic.o src/chunk_dss.c
...
...
sd.o src/tsd.c
ar crus lib/libjemalloc.a src/jemalloc.o src/arena.o src/atomic.o src/base.o src/bitmap.o src/chunk.o src/chunk_dss.o src/chunk_mmap.o src/ckh.o src/ctl.o src/extent.o src/hash.o src/huge.o src/mb.o src/mutex.o src/pages.o src/prof.o src/quarantine.o src/rtree.o src/stats.o src/tcache.o src/util.o src/tsd.o
ar crus lib/libjemalloc_pic.a src/jemalloc.pic.o src/arena.pic.o src/atomic.pic.o src/base.pic.o src/bitmap.pic.o src/chunk.pic.o src/chunk_dss.pic.o src/chunk_mmap.pic.o src/ckh.pic.o src/ctl.pic.o src/extent.pic.o src/hash.pic.o src/huge.pic.o src/mb.pic.o src/mutex.pic.o src/pages.pic.o src/prof.pic.o src/quarantine.pic.o src/rtree.pic.o src/stats.pic.o src/tcache.pic.o src/util.pic.o src/tsd.pic.o
이 다음에 make install을 실행하는데, document를 제외하고 진행하게 하기 위해 다음과 같이 실행한다.
[root@test jemalloc-master]# make install_bin install_include install_lib
install -d /usr/local/bin
install -m 755 bin/jemalloc-config /usr/local/bin
install -m 755 bin/jemalloc.sh /usr/local/bin
install -m 755 bin/jeprof /usr/local/bin
install -d /usr/local/include/jemalloc
install -m 644 include/jemalloc/jemalloc.h /usr/local/include/jemalloc
install -d /usr/local/lib
install -m 755 lib/libjemalloc.so.2 /usr/local/lib
ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so
install -d /usr/local/lib
install -m 755 lib/libjemalloc.a /usr/local/lib
install -m 755 lib/libjemalloc_pic.a /usr/local/lib
install -d /usr/local/lib/pkgconfig
install -m 644 jemalloc.pc /usr/local/lib/pkgconfig
완료 되면 /usr/local/lib에 다음과 같이 jemalloc이 설치되는 것을 확인할 수 있다.
[root@test bin]# cd /usr/local
[root@test local]# ls
bin etc games include lib lib64 libexec sbin share src
[root@test local]# cd lib
[root@test lib]# ls
libjemalloc.a libjemalloc_pic.a libjemalloc.so libjemalloc.so.2 pkgconfig