How to heap profile rust server?

My rust application's memory keep increasing over a time. Every 20 minutes, I can see steady rise of 200mb.

What are the tools I can use to profile rust server?

The classic tool is massif:

valgrind --tool=massif ./target/release/foobar

There's also this that came up on a search just now which looks fancy.

1 Like

I tried valgrind. It seems like program has to exit to show the profile. Ctrl + C is not giving the data.

I'm looking for something where it'll give me sample for a certain period of time.

My program is a tokio server

Valgrind has an option to run via gdb without exiting the program.

valgrind --tool=memcheck --vgdb=yes --vgdb-error=0 ./prog
gdb prog

then in gdb:

(gdb) target remote | vgdb

and then continue and pause execution of the program in gdb, and call in gdb:

monitor leak_check full possibleleak increased