----- Original Message ----
> From: Jesse Becker <[EMAIL PROTECTED]>
> To: Ganglia Developers <[email protected]>
> 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 ? :-)
 
 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.

Cheers
Martin



-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Reply via email to