bug-ncurses
[Top][All Lists]
Advanced

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

memory leak in ncurses 6.0-24.1


From: B J
Subject: memory leak in ncurses 6.0-24.1
Date: Mon, 26 Jun 2017 20:37:18 +0000

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
==17821== 
==17821== 
==17821== HEAP SUMMARY:
==17821==     in use at exit: 829 bytes in 7 blocks
==17821==   total heap usage: 163 allocs, 156 frees, 130,219 bytes allocated
==17821== 
==17821== 12 bytes in 1 blocks are still reachable in loss record 1 of 7
==17821==    at 0x4C2C04F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17821==    by 0x5996119: strdup (in /lib64/libc-2.25.so)
==17821==    by 0x5EC7E14: ??? (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5EC82F7: _nc_first_db (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5ED25D8: _nc_read_entry2 (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5ECB2C8: ??? (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5ECB61F: _nc_setupterm (in /lib64/libtinfo.so.6.0)
==17821==    by 0x4E4BB00: newterm_sp (in /lib64/libncurses.so.6.0)
==17821== 
==17821== 18 bytes in 1 blocks are still reachable in loss record 2 of 7
==17821==    at 0x4C2C04F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17821==    by 0x5ECCEE3: _nc_tparm_analyze (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5ECD21D: tparm (in /lib64/libtinfo.so.6.0)
==17821==    by 0x4E4B2D9: ??? (in /lib64/libncurses.so.6.0)
==17821==    by 0x4E4BDA1: newterm_sp (in /lib64/libncurses.so.6.0)
==17821==    by 0x40081F: test (main.c:5)
==17821==    by 0x4008B8: main (main.c:22)
==17821== 
==17821== 40 bytes in 1 blocks are still reachable in loss record 3 of 7
==17821==    at 0x4C2E065: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17821==    by 0x5EC81FB: _nc_first_db (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5ED25D8: _nc_read_entry2 (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5ECB2C8: ??? (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5ECB61F: _nc_setupterm (in /lib64/libtinfo.so.6.0)
==17821==    by 0x4E4BB00: newterm_sp (in /lib64/libncurses.so.6.0)
==17821==    by 0x40081F: test (main.c:5)
==17821==    by 0x4008B8: main (main.c:22)
==17821== 
==17821== 66 bytes in 1 blocks are still reachable in loss record 4 of 7
==17821==    at 0x4C2E26F: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17821==    by 0x5EC86E2: _nc_doalloc (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5ECE55A: tparm (in /lib64/libtinfo.so.6.0)
==17821==    by 0x4E4B2D9: ??? (in /lib64/libncurses.so.6.0)
==17821==    by 0x4E4BDA1: newterm_sp (in /lib64/libncurses.so.6.0)
==17821==    by 0x40081F: test (main.c:5)
==17821==    by 0x4008B8: main (main.c:22)
==17821== 
==17821== 85 bytes in 1 blocks are still reachable in loss record 5 of 7
==17821==    at 0x4C2C04F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17821==    by 0x5EC8163: _nc_first_db (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5ED25D8: _nc_read_entry2 (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5ECB2C8: ??? (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5ECB61F: _nc_setupterm (in /lib64/libtinfo.so.6.0)
==17821==    by 0x4E4BB00: newterm_sp (in /lib64/libncurses.so.6.0)
==17821==    by 0x40081F: test (main.c:5)
==17821==    by 0x4008B8: main (main.c:22)
==17821== 
==17821== 96 bytes in 1 blocks are definitely lost in loss record 6 of 7
==17821==    at 0x4C2C04F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17821==    by 0x4E40D50: ??? (in /lib64/libncurses.so.6.0)
==17821==    by 0x4E5763C: doupdate_sp (in /lib64/libncurses.so.6.0)
==17821==    by 0x4E4D666: wrefresh (in /lib64/libncurses.so.6.0)
==17821==    by 0x40086E: test (main.c:11)
==17821==    by 0x4008B8: main (main.c:22)
==17821== 
==17821== 512 bytes in 1 blocks are still reachable in loss record 7 of 7
==17821==    at 0x4C2E065: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17821==    by 0x5EC8CFE: _nc_acs_map (in /lib64/libtinfo.so.6.0)
==17821==    by 0x5EC8D21: _nc_init_acs_sp (in /lib64/libtinfo.so.6.0)
==17821==    by 0x4E4F869: ??? (in /lib64/libncurses.so.6.0)
==17821==    by 0x4E4BB7A: newterm_sp (in /lib64/libncurses.so.6.0)
==17821==    by 0x40081F: test (main.c:5)
==17821==    by 0x4008B8: main (main.c:22)
==17821== 
==17821== LEAK SUMMARY:
==17821==    definitely lost: 96 bytes in 1 blocks
==17821==    indirectly lost: 0 bytes in 0 blocks
==17821==      possibly lost: 0 bytes in 0 blocks
==17821==    still reachable: 733 bytes in 6 blocks
==17821==         suppressed: 0 bytes in 0 blocks
==17821== 
==17821== For counts of detected and suppressed errors, rerun with: -v
==17821== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

(I even don't know how to use valgrind...)


reply via email to

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