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 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_global_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
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
export
Export and visualization functionality
smart_pointer_utils
Smart pointer detection and analysis utilities.
test_utils
Testing utilities and helpers
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§

convert_error
Macro for easy error conversion in existing code
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
safe_lock
Macro for safe lock acquisition
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.

Statics§

GLOBAL
Global tracking allocator instance used when the tracking-allocator feature is enabled.

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