Leveraging Heap Profiling and tokio-console to Pinpoint Rust Memory Leak Issue

132 points jeremy_feng

When I was neck-deep in my latest Rust project, I hit a memory leak during a heavy-duty stress test. As any programmer working on a massive project can tell you, pinpointing a memory leak by just eyeballing the code isn't always a walk in the park.

So, in my case, I turned to jemalloc's heap profiling and the tokio-console. And they actually worked pretty well. I was able to pinpoint the bug and squash it, thanks to these nifty tools.

I felt that the experience was too good to keep only to myself, so I recorded the whole process in this blog: the problem, the hunt, the kill. Plus, I've thrown in some key takeaways and tips that my fellow Rustaceans might find useful.

For Rustaceans also struggling with similar issues, you might want to give this a read. Any comment or discussion is highly welcomed!

Full article here: https://greptime.com/blogs/2023-06-15-rust-memory-leaks