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.

15:26 Tuesday, 14 Oct 2003 [#] [computers] (2 comments)

Posted by Perry Lorier at Wed Oct 15 01:37:26 2003:
Some people here had the same problem, so we hacked together a simple malloc debugger that uses LD_PRELOAD.

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. :)
Posted by Lez at Tue Jul 10 12:36:21 2007:
uhh sounds very lame CUPS bug.. Have the CUPS guys ever heard about 'testing'?

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()

Name:


E-mail:


URL:


Add 7 and 7 (required):


Comment: