Hi,<div><br></div><div>I am trying to test a HPC appl'n with jemalloc to see if it can reduce memory fragmentation and slow memory growth of a long running multi-threaded app.</div><div><br></div><div>This application is statically linked as it's not open source and we need one binary distribution to run on multiple Linux versions.</div>

<div><br></div><div>If I configure jemalloc without a jemalloc prefix (je_) and link with -static -ljemalloc I get linker errors for multiply defined symbols</div><div><br></div><div><div>g++  -m64 -Wl,--eh-frame-hdr -o ./bin/xxxx ./obj/xxxx.o  .....   -static -pthread -lcrypto -lz -lbz2 -ldl  -ljemalloc -lunwind -Wl,-Map=gccmaps/xxxx.map</div>

<div>/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':</div><div>/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libc.a(malloc.o): In function `__libc_free':</div>

<div>(.text+0x56b0): multiple definition of `free'</div><div>jemalloc.o:/wd5/downloads/malloc/jemalloc-3.4.0/src/jemalloc.c:1254: first defined here</div><div>/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libc.a(malloc.o): In function `__libc_malloc':</div>

<div>(.text+0x50d0): multiple definition of `malloc'</div><div>jemalloc.o:/wd5/downloads/malloc/jemalloc-3.4.0/src/jemalloc.c:857: first defined here</div><div>/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libc.a(malloc.o): In function `__libc_realloc':</div>

<div>(.text+0x57a0): multiple definition of `realloc'</div><div>jemalloc.o:/wd5/downloads/malloc/jemalloc-3.4.0/src/jemalloc.c:1105: first defined here</div></div><div><br></div><div><br></div><div>If I build with a prefix of je_ then linking is okay but memory allocation is via glibc malloc. The same is true if I dynamically link without a prefix.</div>

<div><br></div><div>Is there any simple easy way to get je_malloc to hook itself in as a replacement for malloc the way tcmalloc does?</div><div><br></div><div>Any help appreciated.</div><div><br></div><div>Thanks, Colin</div>

<div>PS. I have googled for an answer and I really do need to statically link.</div>