pub struct AllocationRegistry;
Expand description
Handles registering tokens for tracking different allocation groups.
Implementations§
Source§impl AllocationRegistry
impl AllocationRegistry
Sourcepub fn enable_tracking()
pub fn enable_tracking()
Enables the tracking of allocations.
Sourcepub fn disable_tracking()
pub fn disable_tracking()
Disables the tracking of allocations.
Sourcepub fn set_global_tracker<T>(tracker: T) -> Result<(), SetTrackerError>
pub fn set_global_tracker<T>(tracker: T) -> Result<(), SetTrackerError>
Sets the global tracker.
Setting a global tracker does not enable or disable the tracking of allocations, so callers
still need to call enable_tracking
after this in order to fully enable tracking.
§Errors
Err(SetTrackerError)
is returned if a global tracker has already been set, otherwise Ok(())
.
Sourcepub fn untracked<F, R>(f: F) -> Rwhere
F: FnOnce() -> R,
pub fn untracked<F, R>(f: F) -> Rwhere
F: FnOnce() -> R,
Runs the given closure without tracking allocations or deallocations.
Inevitably, users of this crate will need to allocate storage for the actual data being tracked. While
AllocationTracker::allocated
and AllocationTracker::deallocated
already avoid reentrantly tracking
allocations, this method provides a way to do so outside of the tracker implementation.