Struct accounting_allocator::AccountingAlloc
source · [−]pub struct AccountingAlloc<A = System> {
pub(crate) thread_counters: OnceBox<ThreadCounters>,
pub(crate) allocator: A,
}
Expand description
A global memory allocator wrapper which counts allocated and deallocated bytes.
Fields
thread_counters: OnceBox<ThreadCounters>
allocator: A
Implementations
sourceimpl AccountingAlloc<System>
impl AccountingAlloc<System>
sourcepub const fn new() -> Self
pub const fn new() -> Self
Create a new AccountingAlloc
using the System
allocator.
sourceimpl<A> AccountingAlloc<A>
impl<A> AccountingAlloc<A>
sourcepub const fn with_allocator(allocator: A) -> Self
pub const fn with_allocator(allocator: A) -> Self
Create a new AccountingAlloc
using the given allocator A
.
Note that in order for AccountingAlloc<A>
to implement GlobalAlloc
, A
must implement GlobalAlloc
.
sourcepub fn count(&self) -> AllocStats
pub fn count(&self) -> AllocStats
Return the latest statistics for this allocator.
Trait Implementations
sourceimpl<A: Debug> Debug for AccountingAlloc<A>
impl<A: Debug> Debug for AccountingAlloc<A>
sourceimpl<A: Default> Default for AccountingAlloc<A>
impl<A: Default> Default for AccountingAlloc<A>
sourcefn default() -> AccountingAlloc<A>
fn default() -> AccountingAlloc<A>
Returns the “default value” for a type. Read more
sourceimpl<A> Display for AccountingAlloc<A>
impl<A> Display for AccountingAlloc<A>
Display the number of bytes each live thread has allocated and deallocated over all time, along with the global total.
sourceimpl<A: GlobalAlloc> GlobalAlloc for AccountingAlloc<A>
impl<A: GlobalAlloc> GlobalAlloc for AccountingAlloc<A>
sourceunsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocate memory as described by the given
layout
. Read moreAuto Trait Implementations
impl<A> RefUnwindSafe for AccountingAlloc<A>where
A: RefUnwindSafe,
impl<A> Send for AccountingAlloc<A>where
A: Send,
impl<A> Sync for AccountingAlloc<A>where
A: Sync,
impl<A> Unpin for AccountingAlloc<A>where
A: Unpin,
impl<A> UnwindSafe for AccountingAlloc<A>where
A: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more