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 with hierarchical structure.
Sourcepub fn export_memory_analysis<P: AsRef<Path>>(
&self,
path: P,
) -> TrackingResult<()>
pub fn export_memory_analysis<P: AsRef<Path>>( &self, path: P, ) -> TrackingResult<()>
Export memory analysis visualization showing variable names, types, and usage patterns. This creates a comprehensive memory analysis with call stack analysis, timeline, and categorization.
§Arguments
path
- Output path for the memory analysis SVG file (recommended: “program_name_memory_analysis.svg”)
Sourcepub fn export_lifecycle_timeline<P: AsRef<Path>>(
&self,
path: P,
) -> TrackingResult<()>
pub fn export_lifecycle_timeline<P: AsRef<Path>>( &self, path: P, ) -> TrackingResult<()>
Export interactive lifecycle timeline showing variable lifecycles and relationships. This creates an advanced timeline with variable birth, life, death, and cross-section interactivity.
§Arguments
path
- Output path for the lifecycle timeline SVG file (recommended: “program_name_lifecycle.svg”)
Sourcepub fn export_to_svg<P: AsRef<Path>>(&self, path: P) -> TrackingResult<()>
👎Deprecated since 0.1.0: Use export_memory_analysis instead
pub fn export_to_svg<P: AsRef<Path>>(&self, path: P) -> TrackingResult<()>
Legacy export method for backward compatibility. Redirects to the new memory analysis export.
§Arguments
path
- Output path for the SVG file