[Gc] gc leaking?

Joseph Gebis gebis at cs.berkeley.edu
Sun Jun 20 16:12:56 PDT 2004

I'm running gc 2.6 on a Xeon, uname -a gives:
Linux x49 2.4.24-lustre.1.0.4-perfctr.2.6.6-mppe #1 SMP Wed Apr 21
21:17:28 PDT 2004 i686 GNU/Linux

I installed the garbage collector to find some memory leaks
in my program.  I #define'd GC_DEBUG in my source code, and
called GC_MALLOC and GC_FREE directly (and never malloc or
free).  Usually, when it found a leak, it would report it
with something that looked like this:

Leaked composite object at 0x80a6b78 (loop.c:16, sz=4)

After fixing all of the leaks with source code refences (a
job made much easier with GC -- thanks!), I was left with some leaks
like this:

Leaked composite object at start: 0x8083000, appr. length: 64

(no source code reference).

To try to discover the source of the leak, I ran gdb on my
program.  It appears to me that that memory location
is referring to some location interal to GC:
235       s = (struct Stream *)GC_MALLOC(sizeof(struct Stream));
(gdb) p s
$7 = (struct Stream *) 0x40196510
(gdb) p *0x8083000
Cannot access memory at address 0x8083000
(gdb) n
236       if(s == NULL) {
(gdb) p s
$8 = (struct Stream *) 0x8081fb8
(gdb) p *0x8083000
$9 = 0

To check if my program did have a memory leak, I compiled a
version of my program without GC (using regular malloc and
free), that repeatedly loops over the main body of allocating
and freeing memory structures.  No matter how long I let
that run, it does not grow in memory size.  My program is

I guess I have a few questions:
1) Is this a leak in GC, or is it really a leak in my program
   that I'm somehow missing?
2) If it is a leak in my program, why aren't source code references
   printed for these leaks, while they were for my other leaks?

Thank you.

More information about the Gc mailing list