mallctl() returns zeroes with jemalloc-prefix
Antony Dovgal
antony.dovgal at gmail.com
Tue Mar 11 04:03:37 PDT 2014
Hello all,
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);
}
int
main(int argc, char **argv)
{
size_t i, sz;
for (i = 0; i < 100; i++) {
do_something(i);
// Update the statistics cached by mallctl.
uint64_t epoch = 1;
sz = sizeof(epoch);
test_mallctl("epoch", &epoch, &sz, &epoch, sz); //PREFIX
// Get basic allocation statistics. Take care to check for
// errors, since --enable-stats must have been specified at
// build time for these statistics to be available.
size_t sz, allocated, active, mapped;
sz = sizeof(size_t);
if (test_mallctl("stats.allocated", &allocated, &sz, NULL, 0) == 0 //PREFIX
&& test_mallctl("stats.active", &active, &sz, NULL, 0) == 0 //PREFIX
&& test_mallctl("stats.mapped", &mapped, &sz, NULL, 0) == 0) { //PREFIX
fprintf(stderr,
"Current allocated/active/mapped: %zu/%zu/%zu\n",
allocated, active, mapped);
}
}
return (0);
}
------------
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.
--
Wbr,
Antony Dovgal
---
http://pinba.org - realtime profiling for PHP
More information about the jemalloc-discuss
mailing list