next
index
prev
6) valgrind, a good tool to detect memory management problems:
valgrind can detect problems such as:
- Use of uninitialized memory
- Reading/writing memory after it has been free'd
- Reading/writing off the end of malloc'd blocks
- Reading/writing inappropriate areas on the stack
- Memory leaks -- where pointers to malloc'd blocks are lost forever
- Passing of uninitialized and/or unaddressable memory to system calls
- Mismatched use of malloc/new/new [] Vs free/delete/delete []
- Some abuses of the POSIX pthread API
valgrind is very easy to use. it has many optional flags you can learn
about from the documentation, valgrind -h
A useful flag is --num-callers=XXX which sets how far back to print the
function call sequence when an error is
detected, (Sometimes the error actually occurs in a function you didn't
write called by another function you
didn't...) by default is num-callers=4.
next
index
prev