Mimalloc

Struct Mimalloc 

Source
pub struct Mimalloc<A: GlobalAlloc> { /* private fields */ }
Expand description

The main allocator object.

A is the type of the OS allocator for segments.

To use it as the global_allocator, wrap it inside a lock and implement GlobalAlloc. See MimallocMutexWrapper.

Implementations§

Source§

impl<A: GlobalAlloc> Mimalloc<A>

Source

pub const fn with_os_allocator(os_alloc: A) -> Self

Create a new Mimalloc instance with an OS allocator.

Source

pub const fn register_deferred_free(&mut self, hook: DeferredFreeHook<A>)

Available on crate feature deferred_free only.

Register a hook to complete deferred free when the allocator needs more memory. A new hook replaces the old one.

See the documentation of mi_register_deferred_free (the extra arg is not supported).

Source

pub fn collect(&mut self)

Collect free memory.

Source

pub unsafe fn alloc(&mut self, layout: Layout) -> *mut u8

GlobalAlloc::alloc but requires a mutable reference &mut self.

§Safety

See GlobalAlloc::alloc.

Source

pub unsafe fn dealloc(&mut self, ptr: *mut u8, _: Layout)

GlobalAlloc::dealloc but requires a mutable reference &mut self.

§Safety

See GlobalAlloc::dealloc.

Trait Implementations§

Source§

impl<A: Default + GlobalAlloc> Default for Mimalloc<A>

Source§

fn default() -> Mimalloc<A>

Returns the “default value” for a type. Read more
Source§

impl<A: GlobalAlloc> Drop for Mimalloc<A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<A: GlobalAlloc> Send for Mimalloc<A>

Auto Trait Implementations§

§

impl<A> Freeze for Mimalloc<A>
where A: Freeze,

§

impl<A> RefUnwindSafe for Mimalloc<A>
where A: RefUnwindSafe,

§

impl<A> !Sync for Mimalloc<A>

§

impl<A> Unpin for Mimalloc<A>
where A: Unpin,

§

impl<A> UnwindSafe for Mimalloc<A>
where A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.