8 typedef int (*
mallctl_t)(
const char *
name,
void *oldp,
size_t *oldlenp,
void *newp,
size_t newlen);
13 const uint64_t *initialise_thread_allocated_p();
14 const uint64_t *initialise_thread_deallocated_p();
17 thread_local
const uint64_t *thread_allocated_p = initialise_thread_allocated_p();
18 thread_local
const uint64_t *thread_deallocated_p = initialise_thread_deallocated_p();
21 const bool have_jemalloc_and_stats = initialise();
25 mallctl = (
mallctl_t)::dlsym(RTLD_DEFAULT,
"mallctl");
26 if (mallctl ==
nullptr)
30 bool enable_stats =
false;
31 size_t bool_s =
sizeof(
bool);
32 mallctl(
"config.stats", &enable_stats, &bool_s,
nullptr, 0);
36 const uint64_t *initialise_thread_allocated_p() {
40 if (have_jemalloc_and_stats)
42 mallctl(
"thread.allocatedp", &stats, &ptr_s,
nullptr, 0);
47 const uint64_t *initialise_thread_deallocated_p() {
51 if (have_jemalloc_and_stats)
53 mallctl(
"thread.deallocatedp", &stats, &ptr_s,
nullptr, 0);
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()