macro_rules! track_var {
($var:expr) => { ... };
}
Expand description
[RECOMMENDED] Track a variable’s memory allocation without taking ownership.
This is the default and recommended tracking macro for most use cases. It performs zero-cost tracking by reference, allowing continued use of the original variable.
§✅ Use this when:
- You want to track memory usage without changing your code
- Performance is critical (zero overhead)
- You need to continue using the variable after tracking
- You’re tracking many variables and don’t want clone overhead
- You’re doing basic memory profiling and analysis
§❌ Don’t use this when:
- You need precise lifecycle tracking with automatic cleanup
- You’re tracking temporary variables that will be moved/consumed immediately
§Example
use memscope_rs::track_var;
let my_vec = vec![1, 2, 3, 4, 5];
track_var!(my_vec); // Zero-cost tracking