pub struct MemoryTracker { /* private fields */ }Expand description
Memory resource tracker to detect potential leaks
Implementations§
Source§impl MemoryTracker
impl MemoryTracker
Sourcepub fn new(leak_threshold_mb: usize) -> Self
pub fn new(leak_threshold_mb: usize) -> Self
Create a new memory tracker with leak detection threshold in MB
Sourcepub fn track_allocation(
&self,
resource_id: String,
size_bytes: usize,
resource_type: &str,
)
pub fn track_allocation( &self, resource_id: String, size_bytes: usize, resource_type: &str, )
Track a memory allocation
Sourcepub fn track_deallocation(&self, resource_id: &str)
pub fn track_deallocation(&self, resource_id: &str)
Mark a resource as deallocated
Sourcepub fn detect_leaks(&self) -> Vec<MemoryLeak>
pub fn detect_leaks(&self) -> Vec<MemoryLeak>
Check for potential memory leaks
Sourcepub fn get_memory_stats(&self) -> (usize, usize, usize)
pub fn get_memory_stats(&self) -> (usize, usize, usize)
Get memory usage summary
Sourcepub fn report_leaks(&self) -> String
pub fn report_leaks(&self) -> String
Report detected leaks
Trait Implementations§
Source§impl Clone for MemoryTracker
impl Clone for MemoryTracker
Source§fn clone(&self) -> MemoryTracker
fn clone(&self) -> MemoryTracker
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryTracker
impl Debug for MemoryTracker
Auto Trait Implementations§
impl Freeze for MemoryTracker
impl RefUnwindSafe for MemoryTracker
impl Send for MemoryTracker
impl Sync for MemoryTracker
impl Unpin for MemoryTracker
impl UnsafeUnpin 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