[leafnode-list] Memory leak (Was: Limiting leafnode run time and/or memory usage?)

Lloyd Zusman ljz at asfast.com
Sun Dec 26 22:44:56 CET 2004


On Sun, Dec 26, 2004 at 02:58:39PM -0500, Lloyd Zusman wrote:
> On Sun, Dec 26, 2004 at 01:56:55PM -0500, Lloyd Zusman wrote:
> > One more thing: this occurs under Linux ...
> > 
> >   % uname -sr
> >   Linux 2.4.20-021stab022.8.777-enterprise
> > 
> > I don't see this problem under FreeBSD.
> 
> ... but when I did the Linux build using dmalloc, the problem seems
> to have gone away ... no more memory leak.

I was wrong when I wrote that.  The memory leak indeed persists
under Linux.  It's just that the unfreed memory increases much more
slowly when using the dmalloc library.






> I used the latest version of dmalloc, which means that I had to
> change some code in critmem_{malloc,calloc,realloc}.c (the *_leap
> routines no longer exist).
> 
> So on this Lunix system, I'll just keep using dmalloc for now.
> 
> Here are the patches to the critmem_* routines so that they
> work with the latest dmalloc library:
> 
> *** critmem_malloc.c.orig       Sun Dec 26 14:54:09 2004
> --- critmem_malloc.c    Sun Dec 26 14:43:23 2004
> ***************
> *** 18,24 ****
>       void *a;
>   
>   #ifdef WITH_DMALLOC
> !     a = _malloc_leap(f, l, size);
>   #else
>       (void)f;
>       (void)l;                  /* shut up compiler warnings */
> --- 18,24 ----
>       void *a;
>   
>   #ifdef WITH_DMALLOC
> !     a = dmalloc_malloc(f, l, size, DMALLOC_FUNC_MALLOC, 0, 0);
>   #else
>       (void)f;
>       (void)l;                  /* shut up compiler warnings */
> *** critmem_calloc.c.orig       Sun Dec 26 14:54:09 2004
> --- critmem_calloc.c    Sun Dec 26 14:41:38 2004
> ***************
> *** 19,25 ****
>       void *a;
>   
>   #ifdef WITH_DMALLOC
> !     a = _calloc_leap(f, l, 1, size);
>   #else
>       (void)f;
>       (void)l;                  /* shut up compiler warnings */
> --- 19,25 ----
>       void *a;
>   
>   #ifdef WITH_DMALLOC
> !     a = dmalloc_calloc(f, l, 1, size, DMALLOC_FUNC_CALLOC, 0);
>   #else
>       (void)f;
>       (void)l;                  /* shut up compiler warnings */
> *** critmem_realloc.c.orig      Sun Dec 26 14:54:09 2004
> --- critmem_realloc.c   Sun Dec 26 14:41:06 2004
> ***************
> *** 18,24 ****
>       void *a;
>   
>   #ifdef WITH_DMALLOC
> !     a = _realloc_leap(f, l, oa, size);
>   #else
>       (void)f;
>       (void)l;                  /* shut up compiler warnings */
> --- 18,24 ----
>       void *a;
>   
>   #ifdef WITH_DMALLOC
> !     a = dmalloc_realloc(f, l, oa, size, DMALLOC_FUNC_REALLOC, 0);
>   #else
>       (void)f;
>       (void)l;                  /* shut up compiler warnings */
> 
> 
> 
> 
> > 
> > On Sun, Dec 26, 2004 at 01:17:25PM -0500, Lloyd Zusman wrote:
> > > I have more information about this issue (see below).
> > > 
> > > There appears to be a significant memory leak in leafnode-20041215a.
> > > 
> > > I'm running this in a local-group-only configuration.  Every time I
> > > issue a "group local.newsgroup" command from within an nntp session,
> > > the leafnode process grabs around 320,000 bytes of memory that it
> > > never releases. This is consistent: each and every time I issue that
> > > command, the memory footprint of the leafnode process increases by
> > > this amount.  This has continued all the way up to 256 meg.
> > > 
> > > I can hack my way around this problem by putting the following line
> > > within the xinetd "service" block quoted at the bottom of this
> > > message.
> > > 
> > >   rlimit_as  4M
> > > 
> > > However, this is not an optimal solution, because it could cause
> > > leafnode to die in the middle of processing a command, thereby
> > > causing users to receive error messages.  The ideal solution is to
> > > fix the memory leak, of course.
> > > 
> > > I thought I'd report this here.  I'll try to find this leak, but it
> > > might take me a while because it's been years since I have dug
> > > through the leafnode code.  Someone else with more familiarity with
> > > the source to leafnode would probably be able to diagnose and fix
> > > this more quickly.
> > > 
> > > 
> > > 
> > > On Sun, Dec 26, 2004 at 07:13:32AM -0500, Lloyd Zusman wrote:
> > > > Is there a way to ensure that leafnode doesn't eat up too much memory?
> > > > 
> > > > I'm using leafnode-20041215a, and I have the following xinetd entry
> > > > for starting up leafnode (see below), but the daemon appears to
> > > > remain running, even when there is no nntp activity.  As time goes
> > > > on and nntp requests are being made, leafnode consumes more and more
> > > > memory until it holds up to 256 meg.
> > > > 
> > > > Is there a way to start up leafnode so that it doesn't remain
> > > > running all the time, or so that it doesn't keep consuming more and
> > > > more memory?
> > > > 
> > > > Thanks in advance.
> > > > 
> > > > Here's my xinetd entry for starting leafnode:
> > > > 
> > > >   # default: on
> > > >   # description: The leafnode NNTP service.
> > > > 
> > > >   service nntp
> > > >   {
> > > >         socket_type = stream
> > > >         protocol    = tcp
> > > >         wait        = no
> > > >         user        = news
> > > >         server      = /usr/local/sbin/leafnode
> > > >   }
> > > > 
> > > > 
> > > > -- 
> > > >  Lloyd Zusman
> > > >  ljz at asfast.com
> > > >  God bless you.
> > > > -- 
> > > > _______________________________________________
> > > > leafnode-list mailing list
> > > > leafnode-list at dt.e-technik.uni-dortmund.de
> > > > http://www.dt.e-technik.uni-dortmund.de/mailman/listinfo/leafnode-list
> > > > http://leafnode.sourceforge.net/
> > > 
> > > -- 
> > >  Lloyd Zusman
> > >  ljz at asfast.com
> > >  God bless you.
> > > -- 
> > > _______________________________________________
> > > leafnode-list mailing list
> > > leafnode-list at dt.e-technik.uni-dortmund.de
> > > http://www.dt.e-technik.uni-dortmund.de/mailman/listinfo/leafnode-list
> > > http://leafnode.sourceforge.net/
> > 
> > -- 
> >  Lloyd Zusman
> >  ljz at asfast.com
> >  God bless you.
> > -- 
> > _______________________________________________
> > leafnode-list mailing list
> > leafnode-list at dt.e-technik.uni-dortmund.de
> > http://www.dt.e-technik.uni-dortmund.de/mailman/listinfo/leafnode-list
> > http://leafnode.sourceforge.net/
> 
> -- 
>  Lloyd Zusman
>  ljz at asfast.com
>  God bless you.
> -- 
> _______________________________________________
> leafnode-list mailing list
> leafnode-list at dt.e-technik.uni-dortmund.de
> http://www.dt.e-technik.uni-dortmund.de/mailman/listinfo/leafnode-list
> http://leafnode.sourceforge.net/

-- 
 Lloyd Zusman
 ljz at asfast.com
 God bless you.



More information about the leafnode-list mailing list