Module allocator

Module allocator 

Source
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§

AllocationStats
Get allocation tracking statistics
TaskTrackingAllocator
Task-aware global allocator wrapper

Functions§

get_allocation_stats
Get current allocation tracking statistics
is_tracking_enabled
Check if task tracking allocator is enabled