[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: memory leak in ncurses 6.0-24.1
From: |
Thomas Dickey |
Subject: |
Re: memory leak in ncurses 6.0-24.1 |
Date: |
Mon, 26 Jun 2017 20:47:43 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Mon, Jun 26, 2017 at 08:37:18PM +0000, B J wrote:
> My code(on openSUSE Tumbleweed):
>
> #include <ncurses.h>
> #include <stdlib.h>
>
> void test() {
> SCREEN *myscr=newterm(getenv("TERM"), stdout, stdin);
>
> WINDOW *w1=newwin_sp(myscr,0,0,0,0);
> WINDOW *w2=newwin_sp(myscr,0,1,0,0); // non-zero size
>
> wrefresh(w1);
> wrefresh(w2); // refresh the non-zero size window later
>
> endwin();
>
> delwin(w1);
> delwin(w2);
> delscreen(myscr);
> }
>
> int main()
> {
> for (;;)
> test();
> }
>
> It's memory usage continues to grow. Is it normal?
>
> Here is my test (endless loop has been removed)
>
> $ valgrind --num-callers=8 --leak-check=yes --show-reachable=yes ./a.out
> ==17821== Memcheck, a memory error detector
> ==17821== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
> ==17821== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
> ==17821== Command: ./test3
Actually, this looks fairly normal: I don't see multiple reports with the
same stack frame, nor are there notes about repeated allocations which are
unfreed.
If you repeated the call to test(), you'd see one or the other of those
repetitions. I ran this against a no-leaks version from the current
snapshot, and see a leak which I'd overlooked:
==122632== 160 bytes in 1 blocks are definitely lost in loss record 5 of 6
==122632== at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==122632== by 0x4E84F11: _nc_doalloc (doalloc.c:55)
==122632== by 0x4E4758A: _nc_scroll_optimize_sp (hardscroll.c:203)
==122632== by 0x4E70E8D: doupdate_sp (tty_update.c:1023)
==122632== by 0x4E6193C: wrefresh (lib_refresh.c:65)
==122632== by 0x4009AA: test (view.c:10)
==122632== by 0x4009F9: main (view.c:25)
==122632==
==122632== 160 bytes in 1 blocks are definitely lost in loss record 6 of 6
==122632== at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==122632== by 0x4E84F11: _nc_doalloc (doalloc.c:55)
==122632== by 0x4E4758A: _nc_scroll_optimize_sp (hardscroll.c:203)
==122632== by 0x4E70E8D: doupdate_sp (tty_update.c:1023)
==122632== by 0x4E6193C: wrefresh (lib_refresh.c:65)
==122632== by 0x4009AA: test (view.c:10)
==122632== by 0x4009FE: main (view.c:26)
That's something that I can fix (thanks).
--
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net
signature.asc
Description: Digital signature