Using jemalloc with static link

Colin Hercus colin at novocraft.com
Fri Jul 19 00:41:41 PDT 2013


Hi,

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.

This application is statically linked as it's not open source and we need
one binary distribution to run on multiple Linux versions.

If I configure jemalloc without a jemalloc prefix (je_) and link with
-static -ljemalloc I get linker errors for multiply defined symbols

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
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o):
In function `dlfcn_globallookup':
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libc.a(malloc.o):
In function `__libc_free':
(.text+0x56b0): multiple definition of `free'
jemalloc.o:/wd5/downloads/malloc/jemalloc-3.4.0/src/jemalloc.c:1254: first
defined here
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libc.a(malloc.o):
In function `__libc_malloc':
(.text+0x50d0): multiple definition of `malloc'
jemalloc.o:/wd5/downloads/malloc/jemalloc-3.4.0/src/jemalloc.c:857: first
defined here
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libc.a(malloc.o):
In function `__libc_realloc':
(.text+0x57a0): multiple definition of `realloc'
jemalloc.o:/wd5/downloads/malloc/jemalloc-3.4.0/src/jemalloc.c:1105: first
defined here


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.

Is there any simple easy way to get je_malloc to hook itself in as a
replacement for malloc the way tcmalloc does?

Any help appreciated.

Thanks, Colin
PS. I have googled for an answer and I really do need to statically link.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jemalloc.net/mailman/jemalloc-discuss/attachments/20130719/4ef7af05/attachment.html>


More information about the jemalloc-discuss mailing list