bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ncurses: tgetent leaks nearly 10 KB of memory every time it is calle


From: Matt
Subject: Re: ncurses: tgetent leaks nearly 10 KB of memory every time it is called
Date: Thu, 15 Jun 2006 16:04:51 -0700
User-agent: Mutt/1.4.2.1i

On Thu, Jun 15, 2006 at 06:30:50PM -0400, Thomas Dickey wrote:
> Matt wrote:
> >I clock it leaking 4 KB for every 200 calls to tgetent, or about
> >20 bytes per call. Sorry, I don't have any more time to investigate
> >it, but I figured I should drop you a note. If you write a little
> >program that calls tgetent(NULL, "vt100") repeatedly you should
> >be able to confirm or deny my observation.
> 
> curious - what sort of application (other than for testing) makes repeated 
> calls to tgetent() for the same $TERM ?

Hi Thomas,

Thanks for the quick response!

GNU screen calls tgetent repeatedly: http://www.gnu.org/software/screen/
  [..adding address@hidden to the Cc list..]

I don't know if you're familiar with it, it's a shell window manager
that enables users to log into a system, start a screen session,
run shells and other programs within that screen session, and then
they can detach and reattach without disturbing their processes.
So it tends to be a long-running process.

GNU screen calls tgetent twice every time a user reattaches to a
screen session. I don't know why it does that, but due to the
memory leak in ncurses version 5.2-20020615, which is what ships
with FreeBSD as the standard curses/terminfo library, GNU screen
leaks 20 KB per session reattachment.

Many users on my system start a screen session and run processes
inside it for months or years, so these leaks add up quick. In the
past six months, my screen session has grown from 6 MB to 83 MB
(I tend to detach and reattach several times a day). My system ran
out of swap space a while back primarily due to this leak.

So, since it's such a pain to upgrade ncurses on FreeBSD (they have
FreeBSD-specific hacks that I don't want to dig into), I'm hacking
a simple tgetent cache into my copy of GNU screen, since those
tgetent calls are just getting the same answer every time. I suspect
it will be at least a year before the FreeBSD folks make a new
release that incorporates ncurses 5.5; until then this hack will
get me by.

I tried installing the FreeBSD port of ncurses 5.5 and linking GNU
screen with that, but it doesn't work right -- it needs the
FreeBSD-specific hacks that have been made to the ncurses build
that the base system uses. It sure would be nice if those hacks
weren't necessary, so I could just drop in the new version of ncurses
and enjoy. Maybe the hacks are for some kind of BSD backward
compatibility? Backward being the key word there. :)

Link to the FreeBSD bug report for reference:
http://www.freebsd.org/cgi/query-pr.cgi?pr=98975

Thanks again,
Matt




reply via email to

[Prev in Thread] Current Thread [Next in Thread]