pub enum Purge {
Default,
Never,
After(Duration),
}Expand description
When memory freed back to an arena is purged (decommitted) to the operating system.
The policy covers arena memory only. Pages above
Config::arena_max_object_size and objects aligned beyond a slice are
mapped directly and unmapped on release. Pinned reservations (see
Reserve) are never purged.
When the kernel supports transparent huge pages and they are allowed (the
default), a purge releases only whole 2 MiB granules freed since the
arena’s last purge. A smaller freed range stays resident until its
neighbors are freed too. The environment can select a finer granule with
MIMALLOC_ALLOW_THP=1 or MIMALLOC_MINIMAL_PURGE_SIZE.
Variants§
Default
mimalloc’s default: its purge delay times its arena multiplier (four seconds in mimalloc 3.5).
Never
Never purge arena memory.
After(Duration)
Purge freed memory after a delay. The first free into an arena after a
purge sets a deadline this far ahead, and the arena is purged at the
first collection after it. A thread collects every 10,000 allocations
that miss its fast path by default, so a process that allocates rarely
can keep freed memory well past the deadline. Delays above
MAX_PURGE_DELAY are clamped, and one below a millisecond purges
each page as it is freed.