Reputation: 27230
see i am just using valgrind for detecting memory leakage in my code. so i have used
valgrind -v --leak-check=full --show-reachable=yes ./my_binary
i see following out which i can not understand
`==16545==
==16545== HEAP SUMMARY:
==16545== in use at exit: 20,171 bytes in 647 blocks
==16545== total heap usage: 993 allocs, 346 frees, 30,090 bytes allocated
==16545==
==16545== Searching for pointers to 647 not-freed blocks
==16545== Checked 124,548 bytes
==16545==
==16545== 1 bytes in 1 blocks are still reachable in loss record 1 of 253
==16545== at 0x400677E: malloc (vg_replace_malloc.c:195)
==16545== by 0x80AAB31: xmalloc (in /bin/bash)
==16545== by 0x80796D0: make_variable_value (in /bin/bash)
==16545== by 0x80798C8: ??? (in /bin/bash)
==16545== by 0x807BA40: initialize_shell_variables (in /bin/bash)
==16545== by 0x805E897: ??? (in /bin/bash)
==16545== by 0x805FA10: main (in /bin/bash)
==16545==
==16545== 1 bytes in 1 blocks are still reachable in loss record 2 of 253
==16545== at 0x400677E: malloc (vg_replace_malloc.c:195)
==16545== by 0x80AAB31: xmalloc (in /bin/bash)
==16545== by 0x80A578B: set_locale_var (in /bin/bash)
==16545== by 0x80A5912: set_default_lang (in /bin/bash)
==16545== by 0x805FA15: main (in /bin/bash)
==16545==
==16545== 1 bytes in 1 blocks are still reachable in loss record 3 of 253
==16545== at 0x400677E: malloc (vg_replace_malloc.c:195)
==16545== by 0x80AAB31: xmalloc (in /bin/bash)
==16545== by 0x8061B9B: ??? (in /bin/bash)
==16545== by 0x8062D95: ??? (in /bin/bash)
==16545== by 0x8065481: ??? (in /bin/bash)
==16545== by 0x806801A: yyparse (in /bin/bash)
==16545== by 0x8060580: parse_command (in /bin/bash)
==16545== by 0x806064F: read_command (in /bin/bash)
==16545== by 0x80608AE: reader_loop (in /bin/bash)
==16545== by 0x805FEFB: main (in /bin/bash)`e
i just want to understand this.? why this does not giving me particular line no in ma code which has not freed ?
Upvotes: 0
Views: 1207
Reputation: 1021
If you want to check the result of an autotools-powered compilation (it really creates a shell script in your build dir), you might want to try this instead:
libtool --mode=execute valgrind -v --leak-check=full --show-reachable=yes ./my_binary
Upvotes: 0
Reputation: 35825
These errors come from /bin/bash
not from your own code. Are you running any bash scripts from your code? Here is explanation of what it means. I think you can just ignore it.
"still reachable" means your program is probably ok -- it didn't free some memory it could have. This is quite common and often reasonable. Don't use --show-reachable=yes if you don't want to see these reports.
Upvotes: 4
Reputation: 146
Have you checked http://valgrind.org/docs/manual/quick-start.html#quick-start.intro ? There is a good documentation there. You shouldn't have used any optimization while you're compiling.
Upvotes: 0
Reputation: 22989
It looks like those addresses belong to your program's code. Perhaps compiling with debug information lets valgrind see line numbers. (Hint: -g switch on gcc)
Upvotes: 1