| Crates.io | memtrack |
| lib.rs | memtrack |
| version | 0.3.0 |
| created_at | 2025-03-26 21:57:39.048943+00 |
| updated_at | 2025-03-26 23:16:05.378618+00 |
| description | A procedural macro for tracking memory usage of functions |
| homepage | |
| repository | https://github.com/akhileshsharma99/memtrack |
| max_upload_size | |
| id | 1607201 |
| size | 14,207 |
A procedural macro for tracking memory usage of Rust functions.
memtrack provides a simple way to monitor memory usage of functions in Rust programs. It works by wrapping functions with memory tracking code that measures the resident set size (RSS) before and after function execution.
Add this to your Cargo.toml:
[dependencies]
memtrack = "0.3.0"
Add the #[track_mem] attribute to the functions you want to track:
use memtrack::track_mem;
#[track_mem]
fn allocate_memory() {
let data: Vec<u8> = vec![0; 1_000_000];
println!("Allocated {} bytes", data.len());
}
This will print the memory usage before and after the function execution.
See the examples/demo.rs file for a more comprehensive example.
cargo run --example demo