MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zmalloc_get_allocator_info

Function zmalloc_get_allocator_info

app/redis-6.2.6/src/zmalloc.c:477–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475#if defined(USE_JEMALLOC)
476
477int zmalloc_get_allocator_info(size_t *allocated,
478 size_t *active,
479 size_t *resident) {
480 uint64_t epoch = 1;
481 size_t sz;
482 *allocated = *resident = *active = 0;
483 /* Update the statistics cached by mallctl. */
484 sz = sizeof(epoch);
485 je_mallctl("epoch", &epoch, &sz, &epoch, sz);
486 sz = sizeof(size_t);
487 /* Unlike RSS, this does not include RSS from shared libraries and other non
488 * heap mappings. */
489 je_mallctl("stats.resident", resident, &sz, NULL, 0);
490 /* Unlike resident, this doesn't not include the pages jemalloc reserves
491 * for re-use (purge will clean that). */
492 je_mallctl("stats.active", active, &sz, NULL, 0);
493 /* Unlike zmalloc_used_memory, this matches the stats.resident by taking
494 * into account all allocations done by this process (not only zmalloc). */
495 je_mallctl("stats.allocated", allocated, &sz, NULL, 0);
496 return 1;
497}
498
499void set_jemalloc_bg_thread(int enable) {
500 /* let jemalloc do purging asynchronously, required when there's no traffic

Callers 2

cronUpdateMemoryStatsFunction · 0.85

Calls 1

je_mallctlFunction · 0.85

Tested by

no test coverage detected