Originally Posted by
Salem
Use valgrind if you're on Unix/Linux.
Ahhh! Thanks!
Now I'm running my program like this: valgrind --leak-check=full ./proj < inp1
This gives me:
Code:
==31508== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 15 from 1)
==31508== malloc/free: in use at exit: 1,602 bytes in 108 blocks.
==31508== malloc/free: 232 allocs, 124 frees, 3,361 bytes allocated.
==31508== For counts of detected errors, rerun with: -v
==31508== searching for pointers to 108 not-freed blocks.
==31508== checked 121,928 bytes.
==31508==
==31508== 116 (64 direct, 52 indirect) bytes in 4 blocks are definitely lost in loss record 7 of 12
==31508== at 0x4005BA5: operator new(unsigned) (vg_replace_malloc.c:163)
==31508== by 0x804A5A4: SCLLRep::Insert(Element*) (SCLL.cpp:57)
==31508== by 0x8048E51: main (proj.cpp:72)
==31508==
==31508==
==31508== 398 bytes in 27 blocks are possibly lost in loss record 12 of 12
==31508== at 0x4005BA5: operator new(unsigned) (vg_replace_malloc.c:163)
==31508== by 0x34071FA: std::string::_Rep::_S_create(unsigned, unsigned, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.8)
==31508== by 0x3407D97: std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned) (in /usr/lib/libstdc++.so.6.0.8)
==31508== by 0x3408947: std::string::reserve(unsigned) (in /usr/lib/libstdc++.so.6.0.8)
==31508== by 0x33DF2E9: std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (in /usr/lib/libstdc++.so.6.0.8)
==31508== by 0x8048E96: main (proj.cpp:77)
==31508==
==31508== LEAK SUMMARY:
==31508== definitely lost: 64 bytes in 4 blocks.
==31508== indirectly lost: 52 bytes in 4 blocks.
==31508== possibly lost: 398 bytes in 27 blocks.
==31508== still reachable: 1,088 bytes in 73 blocks.
==31508== suppressed: 0 bytes in 0 blocks.
==31508== Reachable blocks (those to which a pointer was found) are not shown.
==31508== To see them, rerun with: --show-reachable=yes
Is there a way to get more information about a certain leak?
For example, none of the bolded leaks above have file or line numbers. Can I get more detailed about these specific leaks?