On Feb 19, 2008 7:39 PM, Martin Knoblauch <[EMAIL PROTECTED]> wrote:
> ----- Original Message ----
> > From: Jesse Becker <[EMAIL PROTECTED]>
> > To: Ganglia Developers <ganglia-developers@lists.sourceforge.net>
> > Sent: Tuesday, February 19, 2008 11:25:54 PM
> > Subject: Re: [Ganglia-developers] Memory leak in gmond
> >
> > I'm not sure if this is right--I've only take a really quick check in
> > libmetrics/linux/metrics.c, and my C-fu is rusty.
> >
> > It looks like strndup() is called in linux/metrics.c:hash_lookup
> > (about line 131) to dupliate an interface name, which is included in
> > the stats structure as stats->name.  The net_dev_stats function will
> > return this struct.
> >
> > The function is called in a number of places pkts_in_func,
> > pkts_out_func, bytes_out_func and bytes_in_func.  The variable "*ns"
> > is assigned the output of hash_lookup (e.g. the struct).  Since the
> > 'name' element is malloc()ed, but not explictly freed, it will not go
> > away when *ns goes out of scope.  This is the leak, isn't it?  All
> > four of these functions are very similar, and need to be fixed if this
> > is the case.
> >
> > Or did I miss something obvious? :)
> >
>
>  Lines 137, 148 and 159 ? :-)

I saw those. :-P  I meant after the struct has been returned, outside
the function, the memory is never freed.  Inside that function, it's
okay.

>  The memory allocated in line 151 is never freed, indeed. But it is only
> allocated once per interface and stays alive for the entire lifetime of the
> gmond process. So, it is not leaked.

Ah, that makes more sense, especially if those variables exist for the
lifetime of the program.

So, I've just run gmond under valgrind and duma (a fork of the old
Electric Fence memory debugger), and I can't seem to reproduce the
problem now.  Neither one of them is showing any obvious leaks, at
least not in the 15 minute tests I've run.  The test system(s) are
CentOS4.6 boxes.


-- 
Jesse Becker
GPG Fingerprint -- BD00 7AA4 4483 AFCC 82D0  2720 0083 0931 9A2B 06A2

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Reply via email to