Expand description
§Advanced Memory Profiling for SciRS2
This module provides comprehensive memory profiling capabilities using Pure Rust OS APIs. It enables heap profiling, memory leak detection, and allocation pattern analysis without requiring jemalloc or any C/Fortran dependencies.
§Platform Support
- macOS: Uses
mach_task_self()/task_infovia libc for accurate memory stats - Linux: Reads
/proc/self/statmand/proc/self/statusfor memory stats - Other Unix: Falls back to tracking via global allocator wrapper
- Windows: Uses
windows-sysAPIs for memory info
§Features
- Heap Profiling: Track memory allocations and deallocations
- Leak Detection: Identify memory leaks
- Allocation Patterns: Analyze allocation patterns
- Statistics: Detailed memory statistics
- Zero Overhead: Disabled by default, minimal overhead when enabled
- Pure Rust: No C/Fortran dependencies (COOLJAPAN Policy)
§Example
use scirs2_core::profiling::memory_profiling::{MemoryProfiler, enable_profiling};
// Enable memory profiling
enable_profiling().expect("Failed to enable profiling");
// ... perform allocations ...
// Get memory statistics
let stats = MemoryProfiler::get_stats().expect("Failed to get stats");
println!("Allocated: {} bytes", stats.allocated);
println!("Resident: {} bytes", stats.resident);Structs§
- Allocation
Analysis - Allocation pattern analysis
- Allocation
Tracker - Allocation tracker for detecting patterns
- Memory
Delta - Memory delta from baseline
- Memory
Profiler - Memory profiler
- Memory
Stats - Memory statistics gathered from OS APIs (Pure Rust)
Functions§
- disable_
profiling - Disable memory profiling
- enable_
profiling - Enable memory profiling