pub struct WasmTracingAllocator<A>(pub A)
where
A: GlobalAlloc;
Expand description
A global allocator that traces the Wasm module’s allocations and deallocations.
It wraps some global allocator A
that actually implements the allocation
and deallocation, and inserts its tracing after each invocation.
§Example
Just give it the global allocator A
to wrap, and add the
#[global_allocator]
attribute. The module level documentation has an
example of wrapping the default system allocator. Here is an example of
wrapping wee_alloc
:
ⓘ
// src/lib.rs
use wasm_tracing_allocator::WasmTracingAllocator;
use wee_alloc::WeeAlloc;
#[global_allocator]
static GLOBAL_ALLOCATOR: WasmTracingAllocator<WeeAlloc> =
WasmTracingAllocator(WeeAlloc::INIT);
Tuple Fields§
§0: A
Trait Implementations§
Source§impl<A> Debug for WasmTracingAllocator<A>where
A: GlobalAlloc + Debug,
impl<A> Debug for WasmTracingAllocator<A>where
A: GlobalAlloc + Debug,
Source§impl<A> GlobalAlloc for WasmTracingAllocator<A>where
A: GlobalAlloc,
impl<A> GlobalAlloc for WasmTracingAllocator<A>where
A: GlobalAlloc,
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 moreAuto Trait Implementations§
impl<A> Freeze for WasmTracingAllocator<A>where
A: Freeze,
impl<A> RefUnwindSafe for WasmTracingAllocator<A>where
A: RefUnwindSafe,
impl<A> Send for WasmTracingAllocator<A>where
A: Send,
impl<A> Sync for WasmTracingAllocator<A>where
A: Sync,
impl<A> Unpin for WasmTracingAllocator<A>where
A: Unpin,
impl<A> UnwindSafe for WasmTracingAllocator<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