pub struct MiMalloc;Expand description
The mimalloc global allocator.
Every allocation goes through an aligned mimalloc function, such as
mi_malloc_aligned, so the block meets the alignment of its Layout.
Implementations§
Source§impl MiMalloc
impl MiMalloc
Sourcepub fn version() -> i32
pub fn version() -> i32
Returns the mimalloc version as major * 10000 + minor * 100 + patch,
for example 30503 for v3.5.3.
Sourcepub fn collect(force: bool)
pub fn collect(force: bool)
Returns memory that the current thread no longer uses.
With force, mimalloc also purges unused memory immediately, instead
of after mi_option_purge_delay.
Sourcepub unsafe fn usable_size(ptr: *const u8) -> usize
pub unsafe fn usable_size(ptr: *const u8) -> usize
Returns the usable size in bytes of the block at ptr.
The usable size can be larger than the size that was requested.
§Safety
ptr must be a block that mimalloc allocated and that you have not
freed.
Sourcepub fn process_info() -> ProcessInfo
pub fn process_info() -> ProcessInfo
Returns the time and memory use of the process.
Sourcepub fn stats_json(out: &mut (impl Write + ?Sized)) -> Result
pub fn stats_json(out: &mut (impl Write + ?Sized)) -> Result
Writes the allocation statistics to out as JSON.
§Errors
Returns fmt::Error if mimalloc cannot produce the statistics, or if
out returns an error.
Sourcepub fn stats_print(out: &mut dyn Write) -> Result
pub fn stats_print(out: &mut dyn Write) -> Result
Writes the allocation statistics to out as mimalloc’s text table.
§Errors
Returns fmt::Error if out returns an error.
Sourcepub fn stats_reset()
pub fn stats_reset()
Resets the allocation statistics to zero.
Sourcepub fn process_info_print(out: &mut dyn Write) -> Result
pub fn process_info_print(out: &mut dyn Write) -> Result
Writes the time and memory use of the process to out as mimalloc’s
text table.
§Errors
Returns fmt::Error if out returns an error.
Sourcepub fn option_is_enabled(option: mi_option_t) -> bool
pub fn option_is_enabled(option: mi_option_t) -> bool
Returns whether an option is enabled, which means its value is not 0.
Sourcepub fn option_get(option: mi_option_t) -> c_long
pub fn option_get(option: mi_option_t) -> c_long
Returns the current value of an option.
For an option measured in KiB, the value is in KiB. To get it in bytes,
call option_get_size.
Sourcepub fn option_get_size(option: mi_option_t) -> usize
pub fn option_get_size(option: mi_option_t) -> usize
Returns the current value in bytes of an option measured in KiB.
Sourcepub fn option_set(option: mi_option_t, value: c_long)
pub fn option_set(option: mi_option_t, value: c_long)
Sets an option to value. For an option measured in KiB, value is in
KiB.
The value overrides the build-time default and the MIMALLOC_*
environment variable. It only has an effect if mimalloc reads the option
again afterwards. mimalloc reads some options only at startup, before
main runs. mi_option_t marks them, and the crate documentation
describes how to set them.
use cyo_mimalloc::{MiMalloc, mi_option_t};
// Return unused memory to the 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)
Sets an option to 1, as option_set does.
Sourcepub fn option_disable(option: mi_option_t)
pub fn option_disable(option: mi_option_t)
Sets an option to 0, as option_set does.
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