I have a slow memory leak, which in about 20 hours fills memory. What's current good practice on tools for finding that sort of thing? Jemalloc plus some flame graph generator is suggested in some old messages. That would be fine, but the how-to articles I've found are either old and reference nearly decade old documents.
The Greptime people do this, but they're using Tokio, which I am not.
Also, I need something that doesn't slow down the program much. I'm going to have to run it for hours, then stop it and check what's allocated.
If you record /proc/PID/maps a few times and diff it you can find new memory that is being allocated, then open /proc/PID/mem and seek around to see what's there (or better yet, attach a debugger).
Valgrind's memcheck is excellent when you use it via gdb.
The gdb interface allows you to create heap snapshots at any time, so you can check leaks not when the program exits, but before and after running any part of your program.
I've also tried Massif, which is meh — has only very coarse info when the allocator requests pages from the OS.
dhat was super painfully computer-killing slow for me, and I wasn't able to use it.
Another option is to implement GlobalAlloc yourself, using whatever logging/accounting strategy works for you.