Function libmimalloc_sys::mi_reserve_os_memory_ex

source ·
pub unsafe extern "C" fn mi_reserve_os_memory_ex(
    size: usize,
    commit: bool,
    allow_large: bool,
    exclusive: bool,
    arena_id: *mut mi_arena_id_t
) -> c_int
Expand description

Reserve OS memory for use by mimalloc. Reserved areas are used before allocating from the OS again. By reserving a large area upfront, allocation can be more efficient, and can be better managed on systems without mmap/VirtualAlloc (like WASM for example).

  • size The size to reserve.
  • commit Commit the memory upfront.
  • allow_large Allow large OS pages (2MiB) to be used?
  • exclusive Only allow allocations if specifically for this arena.
  • arena_id Pointer who’s value will be set to the new arena_id if successful.

Returns 0 if successful, and an error code otherwise (e.g. ENOMEM)