Use the dhat crate by enabling its feature flag and wrapping your binary's entry point with dhat::Profiler::new_heap() to generate a heap profile.
fn main() {
let _profiler = dhat::Profiler::new_heap();
// Your application code here
}
Add dhat = { version = "0.3.3", optional = true } to your Cargo.toml dependencies and enable it with cargo run --features dhat.