| 487 | #if defined(USE_JEMALLOC) |
| 488 | |
| 489 | int zmalloc_get_allocator_info(size_t *allocated, |
| 490 | size_t *active, |
| 491 | size_t *resident) { |
| 492 | uint64_t epoch = 1; |
| 493 | size_t sz; |
| 494 | *allocated = *resident = *active = 0; |
| 495 | /* Update the statistics cached by mallctl. */ |
| 496 | sz = sizeof(epoch); |
| 497 | mallctl("epoch", &epoch, &sz, &epoch, sz); |
| 498 | sz = sizeof(size_t); |
| 499 | /* Unlike RSS, this does not include RSS from shared libraries and other non |
| 500 | * heap mappings. */ |
| 501 | mallctl("stats.resident", resident, &sz, NULL, 0); |
| 502 | /* Unlike resident, this doesn't not include the pages jemalloc reserves |
| 503 | * for re-use (purge will clean that). */ |
| 504 | mallctl("stats.active", active, &sz, NULL, 0); |
| 505 | /* Unlike zmalloc_used_memory, this matches the stats.resident by taking |
| 506 | * into account all allocations done by this process (not only zmalloc). */ |
| 507 | mallctl("stats.allocated", allocated, &sz, NULL, 0); |
| 508 | return 1; |
| 509 | } |
| 510 | |
| 511 | void set_jemalloc_bg_thread(int enable) { |
| 512 | /* let jemalloc do purging asynchronously, required when there's no traffic |
no outgoing calls
no test coverage detected