pub struct TrackingAllocator<A: GlobalAlloc>(pub A);
Tuple Fields§
§0: A
Implementations§
source§impl<A: GlobalAlloc> TrackingAllocator<A>
impl<A: GlobalAlloc> TrackingAllocator<A>
sourcepub unsafe fn start_tracking(
&self,
limit: Option<isize>,
failure_handler: Option<Box<dyn Fn() + Send>>,
)
pub unsafe fn start_tracking( &self, limit: Option<isize>, failure_handler: Option<Box<dyn Fn() + Send>>, )
Start tracking memory allocations and deallocations.
§Safety
Failure handler is called with the allocator being in the locked state. Thus, no allocations or deallocations are allowed inside the failure handler; otherwise, a deadlock will occur.
sourcepub fn end_tracking(&self) -> isize
pub fn end_tracking(&self) -> isize
End tracking and return the peak allocation value in bytes (as isize
). Peak allocation
value is not guaranteed to be neither non-zero nor positive.
Trait Implementations§
source§impl<A: GlobalAlloc> GlobalAlloc for TrackingAllocator<A>
impl<A: GlobalAlloc> GlobalAlloc for TrackingAllocator<A>
source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocate 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<A> Freeze for TrackingAllocator<A>where
A: Freeze,
impl<A> RefUnwindSafe for TrackingAllocator<A>where
A: RefUnwindSafe,
impl<A> Send for TrackingAllocator<A>where
A: Send,
impl<A> Sync for TrackingAllocator<A>where
A: Sync,
impl<A> Unpin for TrackingAllocator<A>where
A: Unpin,
impl<A> UnwindSafe for TrackingAllocator<A>where
A: UnwindSafe,
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