BEST PERIOD tool for memory errors, leaks, etc. - Valgrind. Start here . You do not need to do anything special in your code, and this will tell you where the memory was allocated (with a full stack trace, even in C). In addition, it will detect a write to free memory, uninitialized memory usage and much more.
source
share