pub struct MiMalloc;Expand description
The mimalloc global allocator.
Drop-in replacement for the system allocator. Always uses mi_malloc_aligned
internally to guarantee correct alignment for all layouts.
Implementations§
Source§impl MiMalloc
impl MiMalloc
Sourcepub unsafe fn usable_size(ptr: *const u8) -> usize
pub unsafe fn usable_size(ptr: *const u8) -> usize
Usable size of an allocated block (may be larger than requested).
§Safety
ptr must have been allocated by mimalloc.
Sourcepub unsafe fn free_csize(ptr: *mut u8, size: usize)
pub unsafe fn free_csize(ptr: *mut u8, size: usize)
Free a mimalloc block when the allocation size is known.
For small sizes this uses mimalloc’s small-free fast path.
§Safety
ptr must be null or a valid mimalloc allocation, and size must be
the allocation size used for the corresponding allocation.
Sourcepub unsafe fn free_csize_nonnull(ptr: NonNull<u8>, size: usize)
pub unsafe fn free_csize_nonnull(ptr: NonNull<u8>, size: usize)
Free a non-null mimalloc block when the allocation size is known.
For small sizes this uses mimalloc’s non-null small-free fast path.
§Safety
ptr must be a valid mimalloc allocation, and size must be the
allocation size used for the corresponding allocation.
Sourcepub unsafe fn free_small(ptr: *mut u8)
pub unsafe fn free_small(ptr: *mut u8)
Free a small mimalloc block.
§Safety
ptr must be null or a valid mimalloc allocation whose allocation size
is less than or equal to crate::MI_SMALL_SIZE_MAX.
Sourcepub unsafe fn free_small_nonnull(ptr: NonNull<u8>)
pub unsafe fn free_small_nonnull(ptr: NonNull<u8>)
Free a non-null small mimalloc block.
§Safety
ptr must be a valid mimalloc allocation whose allocation size is less
than or equal to crate::MI_SMALL_SIZE_MAX.
Sourcepub fn process_info() -> ProcessInfo
pub fn process_info() -> ProcessInfo
Process memory information.
Sourcepub fn stats_json() -> String
pub fn stats_json() -> String
Allocation statistics as JSON. Returns empty string on failure.
Sourcepub fn stats_print() -> String
pub fn stats_print() -> String
Allocation statistics in mimalloc’s human-readable text format.
Sourcepub fn stats_reset()
pub fn stats_reset()
Reset accumulated mimalloc allocation statistics.
Sourcepub fn process_info_print() -> String
pub fn process_info_print() -> String
Process memory information in mimalloc’s human-readable text format.
Sourcepub fn option_is_enabled(option: mi_option_t) -> bool
pub fn option_is_enabled(option: mi_option_t) -> bool
Check if an option is enabled.
Sourcepub fn option_get(option: mi_option_t) -> c_long
pub fn option_get(option: mi_option_t) -> c_long
Get an option value.
Sourcepub fn option_get_size(option: mi_option_t) -> usize
pub fn option_get_size(option: mi_option_t) -> usize
Get an option value as size (bytes).
Sourcepub fn option_set(option: mi_option_t, value: c_long)
pub fn option_set(option: mi_option_t, value: c_long)
Set an option value.
use rustfs_mimalloc::MiMalloc;
use rustfs_mimalloc_sys::mi_option_t;
// Return memory to OS immediately
MiMalloc::option_set(mi_option_t::mi_option_purge_delay, 0);Sourcepub fn option_enable(option: mi_option_t)
pub fn option_enable(option: mi_option_t)
Enable an option.
Sourcepub fn option_disable(option: mi_option_t)
pub fn option_disable(option: mi_option_t)
Disable an option.
Trait Implementations§
impl Copy for MiMalloc
Source§impl GlobalAlloc for MiMalloc
impl GlobalAlloc for MiMalloc
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
layout. Read moreSource§unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8
alloc, but also ensures that the contents
are set to zero before being returned. Read more