mallctl() returns zeroes with jemalloc-prefix

Jason Evans jasone at canonware.com
Tue Mar 11 08:35:13 PDT 2014


On Mar 11, 2014, at 4:03 AM, Antony Dovgal <antony.dovgal at gmail.com> wrote:
> I'm trying to investigate the following issue:
> jemalloc's mallctl() stops working when the lib is compiled with --with-jemalloc-prefix=<anything>
> Does anyone have any idea how to fix this?
> 
> Here's a quick demonstration of the problem:
> 
> ./configure --prefix=/local --with-jemalloc-prefix=test_ && make install
> 
> Modify the canonical example accordingly:
> ------------
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdint.h>
> #include <jemalloc/jemalloc.h>
> 
> void
> do_something(size_t i)
> {
> 
>        // Leak some memory.
>        malloc(i * 100);

Call test_malloc() instead of malloc() here, and I think your program will work as intended.  Alternatively, you can #define JEMALLOC_MANGLE prior to #include <jemalloc/jemalloc.h>, and all calls to jemalloc APIs will be mangled for you.  The JEMALLOC_MANGLE alternative is more fragile in practice though, so use it with care if at all.

> [...]
> ------------
> 
> And the output of this code looks like this:
> ...
> Current allocated/active/mapped: 0/0/4194304
> Current allocated/active/mapped: 0/0/4194304
> Current allocated/active/mapped: 0/0/4194304
> Current allocated/active/mapped: 0/0/4194304
> ...
> 
> The ctl tree looks ok and the entries are indeed found, but for some reason they are empty (well, except for stats.mapped).
> And yes, everything works fine as long as I don't use any prefix.

Jason


More information about the jemalloc-discuss mailing list