Consumption graph generated with heaptrack.

Memory profiling Rust code in 2019

Since the 1.32 update of Rust, memory profiling with heaptrack became incredibly easy. At least, if you are running Ubuntu 18.04 or newer and can install heaptrack from the repositories. For me, this

sudo apt install heaptrack heaptrack-gui
heaptrack my_binary
heaptrack_gui 'heaptrack.my_binary.somenumber.gz'

was enough to generate the graph shown above and identify the memory hog in my code.

I wrote a small tutorial with a (slightly) more detailed example over on GitHub.

comments powered by Disqus