Crate memscope_rs

Crate memscope_rs 

Source
Expand description

Memory tracking and visualization tools for Rust applications.

This crate provides tools for tracking memory allocations and visualizing memory usage in Rust applications. It includes a custom global allocator that tracks all heap allocations and deallocations, and provides utilities for exporting memory usage data in various formats.

Re-exports§

pub use crate::core::performance_optimizer::OptimizationRecommendations;
pub use crate::core::performance_optimizer::PerformanceMetrics;
pub use crate::core::performance_optimizer::PerformanceOptimizer;
pub use crate::core::ultra_fast_tracker::SamplingStats;
pub use crate::core::ultra_fast_tracker::UltraFastSamplingConfig;
pub use crate::core::ultra_fast_tracker::UltraFastTracker;
pub use export::export_user_variables_binary;
pub use export::export_user_variables_json;
pub use export::export_lifecycle_data;
pub use export::LifecycleExportConfig;
pub use export::LifecycleExporter;
pub use export::binary::detect_binary_type;
pub use export::binary::BinaryParser;
pub use analysis::enhanced_memory_analysis::EnhancedMemoryAnalyzer;
pub use analysis::unsafe_ffi_tracker::get_global_unsafe_ffi_tracker;
pub use analysis::unsafe_ffi_tracker::UnsafeFFITracker;
pub use core::allocator::TrackingAllocator;
pub use core::tracker::memory_tracker::BinaryExportMode;
pub use core::tracker::get_tracker;
pub use core::tracker::ExportOptions;
pub use core::tracker::MemoryTracker;
pub use core::types::AllocationInfo;
pub use core::types::TrackingError;
pub use core::types::TrackingResult;
pub use utils::format_bytes;
pub use utils::get_simple_type;
pub use utils::simplify_type_name;
pub use advanced_types::*;
pub use analysis::*;

Modules§

advanced_trackable_macro
Macro for advanced type Trackable implementations Macro for implementing Trackable for advanced types
advanced_types
Advanced type analysis framework Advanced type analysis framework for complex Rust types
analysis
Advanced memory analysis functionality Memory analysis functionality
async_memory
Async Task-Centric Memory Tracking
classification
Type classification system
cli
Command-line interface functionality Command-line interface functionality
core
Core memory tracking functionality Core memory tracking functionality
enhanced_types
Enhanced types for comprehensive memory analysis Enhanced types for comprehensive memory analysis
error
Unified error handling and recovery system Unified error handling system for MemScope
estimation
Smart size estimation and type classification Intelligent size estimation module
export
Export and visualization functionality
lockfree
Lock-free multi-threaded memory tracking Lock-free multi-threaded memory tracking implementation
memory
Memory management and bounded history tracking Memory Management Module
metrics
Performance monitoring and metrics collection Performance monitoring and metrics collection system
platform
Platform-specific implementations for memory tracking Platform-specific implementations for memory tracking
quality
Code quality assurance and validation system Code quality assurance and validation system
smart_pointer_utils
Smart pointer detection and analysis utilities.
smart_pointers
Smart pointer tracking and analysis Smart pointer tracking and analysis
stack_trace
Enhanced stack trace capture and analysis Enhanced stack trace capture and analysis
test_utils
Testing utilities and helpers
tracking
Memory allocation tracking statistics and monitoring Memory tracking module
unified
Unified backend for intelligent memory tracking
utils
Utility functions Common utility functions shared across modules
variable_registry
Variable registry for lightweight HashMap-based variable tracking Variable Registry - Simple HashMap-based variable name tracking

Macros§

auto_trace
Auto-tracking macro for scoped memory analysis
convert_error
Macro for easy error conversion in existing code
enhanced_system_profile
Enhanced profiling macro for comprehensive system analysis
handle_edge_case
Convenience macro for handling edge cases
impl_advanced_trackable
Macro to implement Trackable for advanced types with automatic analysis
init_test
Macro for quick test initialization
memscope_bail
Macro for creating results with error context
memscope_error
Macro for creating errors with automatic context
safe_lock
Macro for safe lock acquisition
set_task_tracking_allocator
Set the global allocator to use task tracking
track_ffi_alloc
Macro for tracking FFI allocations
track_scope
Macro for tracking scopes with automatic cleanup
track_unsafe_alloc
Macro for tracking unsafe allocations
track_var
[RECOMMENDED] Track a variable’s memory allocation without taking ownership.
track_var_owned
[ADVANCED] Track a variable with full lifecycle management and ownership transfer.
track_var_smart
[SMART] Intelligent tracking that automatically chooses the best strategy.
track_var_with_scope
Enhanced track_var macro that also associates with current scope
try_unwrap_safe
Convenience macro for trying to unwrap safely
unwrap_or_default_safe
Convenience macro for safe unwrapping with default value
unwrap_or_else_safe
Convenience macro for safe unwrapping with default function
unwrap_safe
Convenience macro for safe unwrapping with automatic context
unwrap_safe_at
Convenience macro for safe unwrapping with location

Structs§

TrackedVariable
A wrapper that provides automatic lifecycle tracking for variables.

Traits§

Trackable
Trait for types that can be tracked by the memory tracker.

Functions§

enable_auto_export
Enable automatic JSON export when program ends Call this at the beginning of your program to enable auto-export
init
Initialize the memory tracking system.
init_for_testing
Initialize memscope-rs with optimized settings for testing This reduces logging and disables expensive features for faster test execution