|
From: <mar...@gr...> - 2005-06-07 12:52:11
|
(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
|
|
From: Nicholas N. <nj...@cs...> - 2005-06-12 16:38:51
|
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 |