[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Valgrind reports possibly lost memory
From: |
Thomas Dickey |
Subject: |
Re: Valgrind reports possibly lost memory |
Date: |
Mon, 30 May 2022 19:19:34 -0400 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Mon, May 30, 2022 at 03:17:47PM -0400, Steve Litt wrote:
> Thomas Dickey said on Mon, 30 May 2022 06:01:04 -0400
>
> >On Mon, May 30, 2022 at 10:22:21AM +0200, TheJackiMonster wrote:
> >> Hi,
> >>
> >> I'm currently working on a messaging application using ncurses and
> >> during testing for memory leaks with valgrind I noticed reports from
> >> ncurses.
> >>
> >> To make sure there's nothing coming from my applications code, I
> >> created a very short program to test around.
> >>
> >> test.c:
> >>
> >> #include <stdlib.h>
> >> #include <curses.h>
> >>
> >> int main(int argc, const char** argv)
> >> {
> >> WINDOW *win;
> >> win = initscr();
> >> endwin();
> >> return 0;
> >
> >That's an FAQ:
> >
> >https://invisible-island.net/ncurses/ncurses.faq.html#config_leaks
>
> The valgrind issue is a serious problem because you can't tell whether
> the leak is in ncurses or the code you wrote. Compiling a separate
> ncurses without leak means having two different ncurses', which is a
> problem given that so much Linux software contains ncurses.
>
> It would be wonderful if a single ncurses could operate either way at
> runtime, with an environment variable or a command line argument or the
> existence of a file, or something in a configuration file, or anything
> else detectable at runtime.
sure - but curses doesn't work that way. It keeps memory allocated so that
applications can exit curses-mode temporarily and resume, repainting the
screen just as it was.
It's not the only library doing something like that. I saw some discussion
in the past couple of weeks here on the same theme:
Date: Mon, 16 May 2022 17:45:07 +0100
To: austin-group-l@opengroup.org
Subject: Re: POSIX gettext(): lifetime of returned values
--
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net
signature.asc
Description: PGP signature