valgrind with curses library

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

valgrind with curses library

Martin Porter

(This may be a problem with curses rather than valgrind, but I thought the
valgrind-users list would be a hopeful place to report it.)

I find that vagrind (I am using 2.2.0 on Linux) reports space loss through use
of the curses library.

For example, the program,

---------------------------------------------
#include <stdio.h>
#include <term.h>
#include <ncurses.h>

int main() {
    int r = 0;
    int c = 0;
    char * s;

    setupterm(0, fileno(stdout), (int *)0);
    r = tigetnum("lines");
    c = tigetnum("cols");
    s = tigetstr("cup");
    putp(tparm(s, r - 1, 0));
    printf("(terminal is %d by %d)\n", r, c);

    return 0;
}
---------------------------------------------

compiled with,

gcc -o test -lncurses test.c

and run with 'valgrind ./test' produces,

---------------------------------------------
==4009== Memcheck, a memory error detector for x86-linux.
==4009== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al.
==4009== Using valgrind-2.2.0, a program supervision framework for x86-linux.
==4009== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al.
==4009== For more details, rerun with: -v
==4009==
(terminal is 52 by 99)
==4009==
==4009== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 13 from 1)
==4009== malloc/free: in use at exit: 3267 bytes in 10 blocks.
==4009== malloc/free: 12 allocs, 2 frees, 3303 bytes allocated.
==4009== For a detailed leak analysis,  rerun with: --leak-check=yes
==4009== For counts of detected errors, rerun with: -v
---------------------------------------------

'uname -a' for my machine gives

Linux .. 2.6.8-1-686 #1 Thu Nov 25 04:34:30 UTC 2004 i686 GNU/Linux

1) Is there some way of releasing the space which curses is mallocing
here? I am not aware of any myself, and the little example program
above is more-or-less copied from a textbook.

2) Do I need to worry about the loss of space? Obviously it is a debugging
pain, since I have had to remove curses dependency in the software before I can
confidently debug it through valgrind. But it would be nice to know it was no
more than that.

Martin Porter




-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
Reply | Threaded
Open this post in threaded view
|

Re: valgrind with curses library

njn (Bugzilla)-2
On Tue, 7 Jun 2005, Martin Porter wrote:

> I find that vagrind (I am using 2.2.0 on Linux) reports space loss through use
> of the curses library.
>
> ---------------------------------------------
> ==4009== Memcheck, a memory error detector for x86-linux.
> ==4009== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al.
> ==4009== Using valgrind-2.2.0, a program supervision framework for x86-linux.
> ==4009== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al.
> ==4009== For more details, rerun with: -v
> ==4009==
> (terminal is 52 by 99)
> ==4009==
> ==4009== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 13 from 1)
> ==4009== malloc/free: in use at exit: 3267 bytes in 10 blocks.
> ==4009== malloc/free: 12 allocs, 2 frees, 3303 bytes allocated.
> ==4009== For a detailed leak analysis,  rerun with: --leak-check=yes
> ==4009== For counts of detected errors, rerun with: -v
> ---------------------------------------------
>
> 1) Is there some way of releasing the space which curses is mallocing
> here? I am not aware of any myself, and the little example program
> above is more-or-less copied from a textbook.

Running with --run-libc-freeres=yes might help, but might not.

> 2) Do I need to worry about the loss of space?

Probably not.  Lots of programs don't bother freeing dynamically allocated
memory that is used right until the program's end.  Use --leak-check=yes
if you want to know about genuine memory leaks.

N


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
Reply | Threaded
Open this post in threaded view
|

Re: valgrind with curses library

Martin Porter
In reply to this post by Martin Porter

Nicholas,

Thanks for that info. The  --run-libc-freeres=yes  option was not useful, but

 --leak-check=yes

gives me what's needed, and I've been able to progress.

Martin




-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users