Debugging Sucks
I hate debugging. I hate debugging memory leaks more. I really hate debugging memory leaks when Valgrind won't work.
Today I finally had a poke at the memory leak in gnome-cups-icon in Debian. This isn't a little memory leak, its 20 bytes or so every few seconds, which soon adds up to a 600M process when left running overnight. As Valgrind just refused to play along with Bonobo, I had to resort to more hacky measures:
#include <stdlib.h>
static void
print_usage(void)
{
char buf[256];
sprintf(buf, "grep VmRSS /proc/%d/status", getpid());
system(buf);
}
static char *
get_default (void)
{
...
print_usage();
default_dest = cupsGetDest (NULL, NULL, num_dests, dests);
print_usage ();
...
Urrrgh. In the end I traced the leak to cupsFreeDests() not actually freeing any memory, which sucks.
It's available here:
http://coders.meta.net.nz/~perry/malloc.tar.gz
it's output is a bit of a mess, I've been meaning to clean it up a bit (make it summarise it's output better) but it works well for finding stupidly obvious leaks. :)
I had almost the same experience, except that now, 4 years after your invention that it doesn't free any memory, it frees exactly the half of it :)
To fix the bug they should rename cupsFreeDests() to cupsFreeUpSomeMemory()