Expand description
Usage:
use memscope_rs::async_memory;
#[tokio::main]
async fn main() -> Result<(), async_memory::AsyncError> {
// Initialize tracking
async_memory::initialize()?;
// Use tracked spawn
let handle = async_memory::spawn_tracked(async {
let data = vec![0u8; 1024 * 1024]; // 1MB allocation
// Process the data here
data.len()
});
let result = handle.await;
println!("Processed {} bytes", result);
// Get memory statistics
let snapshot = async_memory::get_memory_snapshot();
println!("Tasks tracked: {}", snapshot.active_task_count());
Ok(())
}
Global allocator hook for async memory tracking
Provides transparent integration with Rust’s global allocator to capture all memory allocation and deallocation events with task attribution.
Structs§
- Allocation
Stats - Get allocation tracking statistics
- Task
Tracking Allocator - Task-aware global allocator wrapper
Functions§
- get_
allocation_ stats - Get current allocation tracking statistics
- is_
tracking_ enabled - Check if task tracking allocator is enabled