Re: [Nagios-devel] Memory leak in Nagios3?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] Memory leak in Nagios3?

Post by Guest »

Ethan Galstad wrote:
> Andreas Ericsson wrote:
>> Hendrik Bäcker wrote:
>>> Hi List,
>>>
>>> after a four days running nagios 3 (latest cvs) I've recognized that my
>>> system has only 80 MByte of free Memory (top).
>>> After stopping Nagios the amount of free memory jumps up to 2,7 GByte.
>>>
>> Are you using embedded perl? It's the single largest memory-sink in Nagios
>> at the moment.
>>
>>> Now my question: What is the best way to find such a leak (if there is one)?
>>>
>> Ues valgrind.
>>
>>> I know tools like valgrind, but I am not familar with right use of it.
>>>
>>> So, if someone can hit me to the right direction, I will try to debug.
>>>
>> man valgrind, or learn how to implement ref-counting in C and add it to
>> Nagios. If done properly, it will eliminate all in-core leaks and leave
>> only the embedded perl ones.
>>
>
> I'm guessing the mem leak is somewhere in the newly rewritten macro
> code. Here's what I do to run valgrind...
>
> Edit base/Makefile and uncomment the "CFLAGS" line below...
>
> # Compiler flags for use with Valgrind
> #CFLAGS=-O0 -g -DHAVE_CONFIG_H @GLIB_INCLUDE@ -DNSCORE
>
> This will override the normal flags used to compile the Nagios daemon.
> Recompile the Nagios daemon:
>
> cd base
> make clean
> make
>
> NOTE: If the large_installation_tweaks option is enabled, you will get a
> lot of errors, because Nagios intentionally does not free memory in
> child processes - it leaves that up to the kernel. I would recomment
> running Nagios with this option disabled in order to track down memory
> leaks.
>
> Run valgrind like so - debug files will be written to
> /tmp/valgrind.[pid] for inspection.
>
> valgrind --log-file=/tmp/valgrind --trace-children=no --leak-check=full
> nagios /usr/local/nagios/etc/nagios.cfg
>
> I just ran this myself and noticed several mem leaks from the new macro
> code. Damn, I thought I ran valgrind before committing the changes.
> Heading out of town today, but I'll get some patches into CVS when I get
> back in a few days.
>

I think I found it. There was a mem leak in the date/time macro
generation code. Patch in CVS now.


Ethan Galstad
Nagios Developer
___
Email: [email protected]
Web: www.nagios.org





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked