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 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
Allocates memory as described by the given
layout. Read moreSource§unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8
Behaves like
alloc, but also ensures that the contents
are set to zero before being returned. Read moreAuto Trait Implementations§
impl Freeze for MiMalloc
impl RefUnwindSafe for MiMalloc
impl Send for MiMalloc
impl Sync for MiMalloc
impl Unpin for MiMalloc
impl UnsafeUnpin for MiMalloc
impl UnwindSafe for MiMalloc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more