memtrack

Crates.iomemtrack
lib.rsmemtrack
version0.3.0
created_at2025-03-26 21:57:39.048943+00
updated_at2025-03-26 23:16:05.378618+00
descriptionA procedural macro for tracking memory usage of functions
homepage
repositoryhttps://github.com/akhileshsharma99/memtrack
max_upload_size
id1607201
size14,207
Akhilesh Sharma (akhileshsharma99)

documentation

https://docs.rs/memtrack

README

memtrack

A procedural macro for tracking memory usage of Rust functions.

Overview

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.

Installation

Add this to your Cargo.toml:

[dependencies]
memtrack = "0.3.0"

Usage

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.

Example

See the examples/demo.rs file for a more comprehensive example.

cargo run --example demo
Commit count: 14

cargo fmt