Trait tracking_allocator::AllocationTracker [−][src]
pub trait AllocationTracker {
fn allocated(
&self,
addr: usize,
size: usize,
group_id: usize,
tags: Option<&'static [(&'static str, &'static str)]>
);
fn deallocated(&self, addr: usize);
}Expand description
Tracks allocations and deallocations.
Required methods
Tracks when an allocation has occurred.
If any tags were associated with the allocation group, they will be provided.
Correctness
Care should be taken to avoid allocating or deallocating in this method itself, as it could cause a recursive call that overflows the stack. Likewise, care should be taken to avoid utilizing resources which depend on mutual exclusion i.e. locks which protect resources that may allocate, as this can potentially lead to deadlocking if not capable of reentrant locking
Implementors should prefer data structures that can pre-allocate their memory, such as bounded channels, as well as intermediate structures that can be allocated entirely on the stack. This will ensure that no allocations are required in this method, while still allowing code to be written that isn’t unnecessarily restrictive.
fn deallocated(&self, addr: usize)
fn deallocated(&self, addr: usize)
Tracks when a deallocation has occurred.
Correctness
Care should be taken to avoid allocating or deallocating in this method itself, as it could cause a recursive call that overflows the stack. Likewise, care should be taken to avoid utilizing resources which depend on mutual exclusion i.e. locks which protect resources that may allocate, as this can potentially lead to deadlocking if not capable of reentrant locking
Implementors should prefer data structures that can pre-allocate their memory, such as bounded channels, as well as intermediate structures that can be allocated entirely on the stack. This will ensure that no allocations are required in this method, while still allowing code to be written that isn’t unnecessarily restrictive.