pub struct MemoryTracker { /* private fields */ }
Expand description
Core memory tracking functionality.
The MemoryTracker maintains records of all memory allocations and deallocations, provides statistics, and supports exporting data in various formats.
Implementations§
Source§impl MemoryTracker
impl MemoryTracker
Sourcepub fn track_allocation(&self, ptr: usize, size: usize) -> TrackingResult<()>
pub fn track_allocation(&self, ptr: usize, size: usize) -> TrackingResult<()>
Track a new memory allocation.
Sourcepub fn track_deallocation(&self, ptr: usize) -> TrackingResult<()>
pub fn track_deallocation(&self, ptr: usize) -> TrackingResult<()>
Track a memory deallocation.
Sourcepub fn associate_var(
&self,
ptr: usize,
var_name: String,
type_name: String,
) -> TrackingResult<()>
pub fn associate_var( &self, ptr: usize, var_name: String, type_name: String, ) -> TrackingResult<()>
Associate a variable name and type with an allocation.
Sourcepub fn get_stats(&self) -> TrackingResult<MemoryStats>
pub fn get_stats(&self) -> TrackingResult<MemoryStats>
Get current memory usage statistics.
Sourcepub fn get_active_allocations(&self) -> TrackingResult<Vec<AllocationInfo>>
pub fn get_active_allocations(&self) -> TrackingResult<Vec<AllocationInfo>>
Get all currently active allocations.
Sourcepub fn get_allocation_history(&self) -> TrackingResult<Vec<AllocationInfo>>
pub fn get_allocation_history(&self) -> TrackingResult<Vec<AllocationInfo>>
Get the complete allocation history.
Sourcepub fn get_memory_by_type(&self) -> TrackingResult<Vec<TypeMemoryUsage>>
pub fn get_memory_by_type(&self) -> TrackingResult<Vec<TypeMemoryUsage>>
Get memory usage grouped by type.
Sourcepub fn export_to_json<P: AsRef<Path>>(&self, path: P) -> TrackingResult<()>
pub fn export_to_json<P: AsRef<Path>>(&self, path: P) -> TrackingResult<()>
Export memory data to JSON format.
Sourcepub fn export_to_svg<P: AsRef<Path>>(&self, path: P) -> TrackingResult<()>
pub fn export_to_svg<P: AsRef<Path>>(&self, path: P) -> TrackingResult<()>
Export memory visualization to SVG format.
Trait Implementations§
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