mi-malloc 3.7/2.5/1.15
Loading...
Searching...
No Matches
Runtime Options and Environment Variables

Set runtime parameters through both programmatic options and environment variables. More...

Enumerations

enum  mi_option_t {
  mi_option_show_errors , mi_option_show_stats , mi_option_verbose , mi_option_max_errors ,
  mi_option_max_warnings , mi_option_reserve_huge_os_pages , mi_option_reserve_huge_os_pages_at , mi_option_reserve_os_memory ,
  mi_option_allow_large_os_pages , mi_option_purge_decommits , mi_option_arena_reserve , mi_option_os_tag ,
  mi_option_retry_on_oom , mi_option_generic_collect , mi_option_allow_thp , mi_option_guarded_min ,
  mi_option_guarded_max , mi_option_unsafe_guarded_precise , mi_option_guarded_sample_rate , mi_option_guarded_sample_seed ,
  mi_option_eager_commit , mi_option_eager_commit_delay , mi_option_arena_eager_commit , mi_option_abandoned_page_purge ,
  mi_option_purge_delay , mi_option_use_numa_nodes , mi_option_disallow_os_alloc , mi_option_max_segment_reclaim ,
  mi_option_destroy_on_exit , mi_option_arena_purge_mult , mi_option_abandoned_reclaim_on_free , mi_option_purge_extend_delay ,
  mi_option_disallow_arena_alloc , mi_option_visit_abandoned , mi_option_target_segments_per_thread , mi_option_page_reclaim_on_free ,
  mi_option_page_full_retain , mi_option_page_max_candidates , mi_option_max_vabits , mi_option_pagemap_commit ,
  mi_option_page_commit_on_demand , mi_option_page_max_reclaim , mi_option_page_cross_thread_max_reclaim , mi_option_minimal_purge_size ,
  mi_option_arena_max_object_size , _mi_option_last
}
 Runtime options. More...

Functions

void mi_options_print (void)
 Print out all runtime parameters for mimalloc.
void mi_options_print_out (mi_output_fun *out, void *arg)
 Print out all process info.
bool mi_option_is_enabled (mi_option_t option)
void mi_option_enable (mi_option_t option)
void mi_option_disable (mi_option_t option)
void mi_option_set_enabled (mi_option_t option, bool enable)
void mi_option_set_enabled_default (mi_option_t option, bool enable)
long mi_option_get (mi_option_t option)
long mi_option_get_clamp (mi_option_t option, long min, long max)
size_t mi_option_get_size (mi_option_t option)
void mi_option_set (mi_option_t option, long value)
void mi_option_set_default (mi_option_t option, long value)

Detailed Description

Set runtime parameters through both programmatic options and environment variables.

Besides setting them programmatically with mi_option_set(), all options can also be set through environment variables named MIMALLOC_<option>, where <option> is the option name without the mi_option_ prefix in upper case. For example:

> env MIMALLOC_SHOW_STATS=1 MIMALLOC_ARENA_RESERVE=256MiB ./myprogram

sets mi_option_show_stats and mi_option_arena_reserve. Boolean options accept 1, true, yes, or on (and 0, false, no, or off), and size options accept a K, M, G, or T suffix (optionally followed by iB or B). Most environment options are ignored in elevated processes (like a setuid executable), and in secure builds some options that weaken security are ignored as well.

When mimalloc is built with cmake -DMI_ENV_PREFIX=<PREFIX>, the environment variables are named <PREFIX>_MIMALLOC_<option> instead (and plain MIMALLOC_<option> variables are ignored). For example, with -DMI_ENV_PREFIX=MYAPP the statistics are shown with MYAPP_MIMALLOC_SHOW_STATS=1. This is useful to isolate the options when multiple instances of mimalloc are loaded in the same process. The prefix must be an identifier of at most 16 characters.

Enumeration Type Documentation

◆ mi_option_t

Runtime options.

Options prefixed with mi_option_deprecated_... have been removed from mimalloc and no longer have any effect.

Enumerator
mi_option_show_errors 

Print error messages.

mi_option_show_stats 

Print statistics on termination.

mi_option_verbose 

Print verbose messages.

mi_option_max_errors 

issue at most N error messages

mi_option_max_warnings 

issue at most N warning messages

mi_option_reserve_huge_os_pages 

reserve N huge OS pages (1GiB pages) at startup

mi_option_reserve_huge_os_pages_at 

Reserve N huge OS pages at a specific NUMA node N.

mi_option_reserve_os_memory 

reserve specified amount of OS memory in an arena at startup (internally, this value is in KiB; use mi_option_get_size())

mi_option_allow_large_os_pages 

allow large (2 or 4 MiB) OS pages, implies eager commit.

mi_option_purge_decommits 

should a memory purge decommit? (=1). Set to 0 to use memory reset on a purge (instead of decommit)

mi_option_arena_reserve 

initial memory size for arena reservation (= 1 GiB on 64-bit) (internally, this value is in KiB; use mi_option_get_size())

mi_option_os_tag 

tag used for OS logging (macOS only for now) (=100)

mi_option_retry_on_oom 

retry on out-of-memory for N milli seconds (=400), set to 0 to disable retries. (only on windows)

mi_option_generic_collect 

collect heaps every N (=10000) generic allocation calls

mi_option_allow_thp 

Transparent huge pages: 0 disable for the process, 1 allow, 2 allow and avoid splitting on purge. Default: 2 on Linux, 0 on Android; an explicit mi_option_minimal_purge_size overrides the purge behavior.

mi_option_guarded_min 

only used when building with MI_GUARDED: minimal rounded object size for guarded objects (=0)

mi_option_guarded_max 

only used when building with MI_GUARDED: maximal rounded object size for guarded objects (=0)

mi_option_unsafe_guarded_precise 

disregard minimal alignment requirement to always place guarded blocks exactly in front of a guard page (=0)

mi_option_guarded_sample_rate 

guard an object in the min/max range about every N requested bytes (=0)

mi_option_guarded_sample_seed 

can be set to allow for a (more) deterministic re-execution when a guard page is triggered (=0)

mi_option_eager_commit 

v1,v2: eager commit segments? (after eager_commit_delay segments) (enabled by default).

mi_option_eager_commit_delay 

v2: the first N segments per thread are not eagerly committed (but per page in the segment on demand)

mi_option_arena_eager_commit 

eager commit arenas? Use 2 to enable just on overcommit systems (=2)

mi_option_abandoned_page_purge 

v1,v2: immediately purge delayed purges on thread termination

mi_option_purge_delay 

memory purging is delayed by N milli seconds; use 0 for immediate purging or -1 for no purging at all. (=10)

mi_option_use_numa_nodes 

0 = use all available numa nodes, otherwise use at most N nodes.

mi_option_disallow_os_alloc 

1 = do not use OS memory for allocation (but only programmatically reserved arenas)

mi_option_max_segment_reclaim 

v2: max. percentage of the abandoned segments can be reclaimed per try (=10%)

mi_option_destroy_on_exit 

if set, release all memory on exit; sometimes used for dynamic unloading but can be unsafe

mi_option_arena_purge_mult 

multiplier for purge_delay for the purging delay for arenas (=10)

mi_option_abandoned_reclaim_on_free 

v1,v2: allow to reclaim an abandoned segment on a free (=1)

mi_option_purge_extend_delay 

v1,v2: extend purge delay on each subsequent delay (=1)

mi_option_disallow_arena_alloc 

1 = do not use arena's for allocation (except if using specific arena id's)

mi_option_visit_abandoned 

v1,v2: allow visiting heap blocks from abandoned threads (=0)

mi_option_target_segments_per_thread 

v1,v2: experimental (=0)

mi_option_page_reclaim_on_free 

v3: reclaim abandoned pages on a free (=0). -1 disallowr always, 0 allows if the page originated from the current theap, 1 allow always

mi_option_page_full_retain 

v3: retain N full (small) pages per size class (=2). Use -1 for infinite (as in v1,v2).

mi_option_page_max_candidates 

v3: max candidate pages to consider for allocation (=4)

mi_option_max_vabits 

v3: max user space virtual address bits to consider (=48)

mi_option_pagemap_commit 

v3: commit the full pagemap (to always catch invalid pointer uses) (=0)

mi_option_page_commit_on_demand 

v3: commit page memory on-demand (=0)

mi_option_page_max_reclaim 

v3: don't reclaim pages of the same originating theap if we already own N pages (in that size class) (=-1 (unlimited))

mi_option_page_cross_thread_max_reclaim 

v3: don't reclaim pages across threads if we already own N pages (in that size class) (=16)

mi_option_minimal_purge_size 

v3: set minimal purge size (in KiB) (=0). By default set to either 64 or 2048 if THP is enabled. (internal value is in KiB so use mi_option_get_size())

mi_option_arena_max_object_size 

v3: set maximal object size that can be allocated in an arena (in KiB) (=2GiB on 64-bit).

_mi_option_last 

Function Documentation

◆ mi_option_disable()

void mi_option_disable ( mi_option_t option)

◆ mi_option_enable()

void mi_option_enable ( mi_option_t option)

◆ mi_option_get()

long mi_option_get ( mi_option_t option)

◆ mi_option_get_clamp()

long mi_option_get_clamp ( mi_option_t option,
long min,
long max )

◆ mi_option_get_size()

size_t mi_option_get_size ( mi_option_t option)

◆ mi_option_is_enabled()

bool mi_option_is_enabled ( mi_option_t option)

◆ mi_option_set()

void mi_option_set ( mi_option_t option,
long value )

◆ mi_option_set_default()

void mi_option_set_default ( mi_option_t option,
long value )

◆ mi_option_set_enabled()

void mi_option_set_enabled ( mi_option_t option,
bool enable )

◆ mi_option_set_enabled_default()

void mi_option_set_enabled_default ( mi_option_t option,
bool enable )

◆ mi_options_print()

void mi_options_print ( void )

Print out all runtime parameters for mimalloc.

Also printed with MIMALLOC_VERBOSE=1 at startup.

◆ mi_options_print_out()

void mi_options_print_out ( mi_output_fun * out,
void * arg )

Print out all process info.

Parameters
outAn output function or NULL for the default.
argOptional argument passed to out (if not NULL) Also printed with MIMALLOC_VERBOSE=1 at startup.
See also
mi_options_print()