[OS X] Configuring jemalloc via je_malloc_conf

David Rigby daver at couchbase.com
Thu Sep 4 09:14:35 PDT 2014


Hi,

I’m having some problems using je_malloc_conf to configure jemalloc’s runtime behaviour, but *only on OSX* - Linux is fine. The behaviour I see is that any je_malloc_conf setting on OS X Mavericks (clang-503.0.40) is ignored, but works perfectly when compiling on Ubuntu 14.04, x86_64, gcc 4.8.2)

I’m defining je_malloc_conf as:

    const char* je_malloc_conf = "narenas:1";

Full reproducer is at: https://github.com/daverigby/jemalloc_conf/blob/master/app.c

>From what I can tell, it appears that under linux the je_malloc_conf symbols in libjemalloc and my app are correctly merged by the dynamic linker, but under OS X I there are duplicate symbols, and malloc_conf_init() sees the (NULL) definition in the library:

(lldb) bt 3
* thread #1: tid = 0x7c0445, 0x0000000100011725 libjemalloc.2.dylib`jemalloc_constructor [inlined] malloc_conf_init + 147 at jemalloc.c:477, queue = 'com.apple.main-thread, stop reason = breakpoint 2.10
  * frame #0: 0x0000000100011725 libjemalloc.2.dylib` jemalloc_constructor [inlined] malloc_conf_init  + 147 at jemalloc.c:477
    frame #1: 0x0000000100011692 libjemalloc.2.dylib` jemalloc_constructor [inlined] malloc_init_hard  + 34 at jemalloc.c:761
    frame #2: 0x0000000100011670 libjemalloc.2.dylib` jemalloc_constructor [inlined] malloc_init  + 228 at jemalloc.c:357
(lldb) p je_malloc_conf
(const char *) $0 = 0x0000000000000000
(lldb) image lookup --symbol je_malloc_conf
1 symbols match 'je_malloc_conf' in ./app:
        Address: app[0x0000000100001028] (app.__DATA.__data + 0)
        Summary:
1 symbols match 'je_malloc_conf' in /Users/dave/lib/libjemalloc.2.dylib:
        Address: libjemalloc.2.dylib[0x0000000000033c00] (libjemalloc.2.dylib.__DATA.__common + 112)
        Summary: libjemalloc.2.dylib`je_malloc_conf

Can anyone suggest what I’m doing wrong, and what’s necessary to be able to set je_malloc_conf in my (OS X) application?


Thanks,

Dave Rigby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jemalloc.net/mailman/jemalloc-discuss/attachments/20140904/7d7acc4c/attachment.html>


More information about the jemalloc-discuss mailing list