jemalloc linking

Mayank Kumar (mayankum) mayankum at cisco.com
Mon May 18 09:30:04 PDT 2015


Hi All

My application worked perfectly with LD_PRELOAD and the virtual memory growth was contained. As soon as I linked it dynamically with jemalloc, this wasn't the case. So virtual memory kept growing. So  I am guessing that my application is still not using jemalloc but libc's default malloc when linking dynamically. My application is a binary which links to many dynamically loadable libraries some of which are internally built and some are open source versions which we don't always build. My questions are:-


1.       When linking dynamically with jemalloc, is it a requirement to have -ljemalloc as early as possible or possibly the first library being linked to, to override the default malloc ?

2.       What method does jemalloc uses while linking to override malloc, does it use the malloc_hooks to override or just the normal linking, so that whatever the linker gets first, it will link to .

3.       Would linking statically  solve this issue, although my preference would be to link dynamically since I have at least 10 processes which needs jemalloc, and at least they would share the code in memory.

4.       When linking with external open source libraries, do I need to re-compile those with jemalloc as well to make sure any mallocs in those libraries also go through jemalloc or that is not required. I am guessing it should not be required as long as my process links to the right malloc library, their dependencies should be correctly resolved.

-Mayank



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jemalloc.net/mailman/jemalloc-discuss/attachments/20150518/fe34f3b1/attachment.html>


More information about the jemalloc-discuss mailing list