9 int (*
mallctl_t)(
const char *
name,
void *oldp,
size_t *oldlenp,
void *newp,
size_t newlen);
14 const uint64_t * initialise_thread_allocated_p();
15 const uint64_t * initialise_thread_deallocated_p();
18 thread_local
const uint64_t * thread_allocated_p = initialise_thread_allocated_p();
19 thread_local
const uint64_t * thread_deallocated_p = initialise_thread_deallocated_p();
22 const bool have_jemalloc_and_stats = initialise();
28 mallctl = (
mallctl_t) ::dlsym(RTLD_DEFAULT,
"mallctl");
29 if (mallctl ==
nullptr)
33 bool enable_stats =
false;
34 size_t bool_s =
sizeof(bool);
35 mallctl(
"config.stats", & enable_stats, & bool_s,
nullptr, 0);
39 const uint64_t * initialise_thread_allocated_p()
44 if (have_jemalloc_and_stats)
46 mallctl(
"thread.allocatedp", & stats, & ptr_s,
nullptr, 0);
51 const uint64_t * initialise_thread_deallocated_p()
56 if (have_jemalloc_and_stats)
58 mallctl(
"thread.deallocatedp", & stats, & ptr_s,
nullptr, 0);
67 return have_jemalloc_and_stats;
72 return * thread_allocated_p;
77 return * thread_deallocated_p;
int(* mallctl_t)(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen)
static uint64_t deallocated()
static bool is_available()
unsigned long long uint64_t
static uint64_t allocated()