31#include <flow/error/error.hpp>
32#include <flow/log/log.hpp>
33#include <flow/util/string_view.hpp>
34#include <jemalloc/jemalloc.h>
131 public extent_hooks_t
236 void deallocate(
void* address)
const noexcept;
294 template<
typename On_done_func>
364 flow::log::Sev sev = flow::log::Sev::S_INFO,
util::String_view extra_opts = {})
const;
397 extent_hooks_t(std::move(extent_hooks)),
409template<
typename On_done_func>
411 On_done_func&& on_done_func)
const
Wrapper around extent hooks, which are callbacks that can be instituted in jemalloc per arena.
T * get_owner() const
Returns the value owner as given to ctor earlier.
T * m_owner
The holder of this object.
Extent_hooks_wrapper(extent_hooks_t &&extent_hooks, T *owner)
Constructor.
arena_id_t create_arena(extent_hooks_t *extent_hooks) const
Creates a new segregated memory area (jemalloc-arena), wired to the given extent hooks (if any).
void deallocate_helper(void *address, int thread_cache_flags) const noexcept
Boring helper for deallocate_no_tcache() and deallocate(address, tcache_id).
void stats_dump_to_ostream(std::ostream &os=std::cout, Stat_format format=Stat_format::S_TEXT, util::String_view extra_opts={}) const
Writes a broad, raw, process-wide jemalloc statistics dump (all arenas) to os.
std::string stats_dump_to_string(Stat_format format=Stat_format::S_TEXT, util::String_view extra_opts={}) const
Like stats_dump_to_ostream() but returns the dump as a string.
void deallocate(void *address) const noexcept
Deallocates memory by using jemalloc's vanilla free() implementation.
void * allocate_no_tcache(size_t size, arena_id_t arena_id) const
Allocates uninitialized memory, in the specified jemalloc-arena, without the use of a thread cache.
void destroy_arena(arena_id_t arena_id, const flow::log::Log_context_mt *log_ctx, On_done_func &&on_done_func) const
Forwards to Thread_cache::destroy_arena_safely().
void deallocate_no_tcache(void *address) const noexcept
Deallocates memory similarly to deallocate(address), except that this is done without the use of a th...
void * allocate(size_t size) const
Allocates uninitialized memory by using jemalloc's vanilla malloc() implementation.
Stat_format
Output format for stats_dump_to_ostream() and the sibling stats-dump methods.
@ S_TEXT
Human-readable text (jemalloc malloc_stats_print() default formatting).
void * allocate_helper(size_t size, arena_id_t arena_id, int thread_cache_flags) const
Boring helper for allocate_no_tcache() and allocate(size, arena_id, tcache_id).
void log_stats_dump(flow::log::Logger *logger_ptr, Stat_format format=Stat_format::S_TEXT, flow::log::Sev sev=flow::log::Sev::S_INFO, util::String_view extra_opts={}) const
Like stats_dump_to_ostream() but logs the dump – as a single (multi-line) message – via logger_ptr at...
static void destroy_arena_safely(arena_id_t arena_id, const flow::log::Log_context_mt *log_ctx, On_done_func &&on_done_func)
Destroys (as by mallctl("arena.X.destroy")) the given jemalloc arena, as soon as it is safe without c...
ipc::shm sub-module with the SHM-jemalloc SHM-provider. See ipc::shm doc header for introduction.
unsigned int arena_id_t
Arena ID as dictated by jemalloc.
unsigned int tcache_id_t
Thread cache ID type as dictated by jemalloc.
flow::util::String_view String_view
Short-hand for Flow's String_view.