My day job requires me to spend a lot of time in Linux terminals, hammering away at MariaDB ColumnStore to write and test new code as well as finding and fixing bugs. I have decided to write about the tools I use to get the job done, especially newer ones I have discovered.
The first tool I’m going to talk about is ack. ack is a replacement for grep which is designed to be used on files. By default it will scan the current directory and subdirectories for the given text. You can also tell it to only scan certain file types.
In the example below I’ve asked it to search for the word “Token” in the current codebase in all C++ header file types.
I have found more often than not I am reaching for ack instead of grep when searching codebases for certain content because it already uses by default the options I would use in grep and is easy to filter by file type. I now have to remember to install it on all my machines and VMs when setting them up as I naturally go to it first.
Memleakx is a tool I found completely by accident recently but has been really useful in solving a recent complex memory leak issue (which turned out to be down to orphaned threads). It was created by Wu Bingzheng who I have crossed paths with before during my days working at NGINX.
It is similar to Valgrind’s memcheck but has the added advantage that you can attach it to an already running process. Something I have been dying for Valgrind to have since I’m usually debugging long-running daemons. Or I’m debugging daemons that have an extremely long setup time when running under Valgrind.
You can tell memleakx to spit out reports every X seconds of the allocations that have been made but not freed yet. Making it extremely useful to find things may not technically be leaks as they will be cleaned up later, but can still consume a lot of RAM when not needed.
It appears to have similar CPU overheads as Valgrind, I haven’t looked at its source code to see what it does internally yet.
If you are doing a lot of memory debugging I highly recommend adding this one to your toolbox. It doesn’t appear to be in any repositories yet so you have to get the source from GitHub or the RPM/DEB packages.
Image credit: Biser Todorov, used under a Creative Commons license.