pub struct MemoryTracker { /* private fields */ }Expand description
Memory usage tracking and management
Implementations§
Source§impl MemoryTracker
impl MemoryTracker
Sourcepub fn new(limit_mb: Option<usize>) -> Self
pub fn new(limit_mb: Option<usize>) -> Self
Create a new memory tracker with optional limit (in MB)
Sourcepub fn allocate(&mut self, size_mb: usize) -> Result<(), MemoryError>
pub fn allocate(&mut self, size_mb: usize) -> Result<(), MemoryError>
Allocate memory and track usage
Sourcepub fn deallocate(&mut self, size_mb: usize)
pub fn deallocate(&mut self, size_mb: usize)
Deallocate memory and update tracking
Sourcepub fn current_usage(&self) -> usize
pub fn current_usage(&self) -> usize
Get current memory usage in MB
Sourcepub fn peak_usage(&self) -> usize
pub fn peak_usage(&self) -> usize
Get peak memory usage in MB
Auto Trait Implementations§
impl Freeze for MemoryTracker
impl RefUnwindSafe for MemoryTracker
impl Send for MemoryTracker
impl Sync for MemoryTracker
impl Unpin for MemoryTracker
impl UnwindSafe for MemoryTracker
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more