Page 1 of 1

Re: [Nagios-devel] [Fwd: Memory leak in Nagios head]

Posted: Mon Nov 29, 2004 9:22 pm
by Guest
--=-/Ch4PxEn4mlSJrgM3vUK
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Mon, 2004-11-29 at 15:34, Andreas Ericsson wrote:
> Matthew Kent wrote:
> > Forwarding this on in case anyone else has seen this behaviour and has
> > some suggestions. I'll give it a run through valgrind and see if I can
> > spot anything this evening.
> >
>
> Thanks, Matt.
>
> A small update;
>
> After having run the daemon about 10 hours at a test system, memory
> consumption has escalated from roughly 1MB to around 24MB. Not very nice
> figures. It seems that sending a HUP makes memory consumption make a
> small jump (usually around 20K).

Well I may have trapped the HUP problem after some passes through
valgrind. Seems reset_variables was getting called twice, right after
receiving a sighup and immediately after at the start of the main do()
loop in nagios.c

I've removed the call to it from cleanup() as it's only called when
erroring out anyway, and resetting the variables at this point is a bit
of a lost cause ;)

I also fixed a couple other minor items reported by valgrind. Although I
couldn't figure out this last one

64 bytes in 8 blocks are definitely lost in loss record 66 of 118
at 0x1B904EDD: malloc (vg_replace_malloc.c:131)
by 0x808F4D4: xodtemplate_add_host_to_hostlist (xodtemplate.c:10665)
by 0x808F456: xodtemplate_add_hostgroup_members_to_hostlist
(xodtemplate.c:10640)
by 0x808EF0E: xodtemplate_expand_hostgroups (xodtemplate.c:10434)

Patch against cvs head.
--
Matthew Kent
http://magoazul.com

--=-/Ch4PxEn4mlSJrgM3vUK
Content-Disposition: attachment; filename=nagios-2.0a1-memory_cleanup.patch
Content-Type: text/x-patch; name=nagios-2.0a1-memory_cleanup.patch; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit

diff -u3 -r nagios_orig/base/config.c nagios/base/config.c
--- nagios_orig/base/config.c 2004-11-29 18:27:58.000000000 -0500
+++ nagios/base/config.c 2004-11-29 22:20:11.000000000 -0500
@@ -900,6 +900,8 @@
break;
}

+ if (log_archive_path!=NULL)
+ free(log_archive_path);
log_archive_path=(char *)strdup(value);
strip(log_archive_path);

@@ -1566,9 +1568,8 @@
if(user_index>=0 && user_index<MAX_USER_MACROS){
if(macro_user[user_index]!=NULL)
free(macro_user[user_index]);
- macro_user[user_index]=(char *)malloc(strlen(value)+1);
+ macro_user[user_index]=strdup(value);
if(macro_user[user_index]!=NULL){
- strcpy(macro_user[user_index],value);
#ifdef DEBUG1
printf("\t\t$USER%d$ set to '%s'\n",user_index+1,macro_user[user_index]);
#endif
diff -u3 -r nagios_orig/base/utils.c nagios/base/utils.c
--- nagios_orig/base/utils.c 2004-11-29 18:27:58.000000000 -0500
+++ nagios/base/utils.c 2004-11-29 22:03:00.000000000 -0500
@@ -4978,9 +4978,6 @@
/* free all allocated memory */
free_memory();

- /* reset global variables to default values */
- reset_variables();
-
/* clear all macros */
clear_volatile_macros();
clear_nonvolatile_macros();

--=-/Ch4PxEn4mlSJrgM3vUK--






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