6 ms·
I develop applications in C++ on Linux and Windows. On windows I can enable heap tracing and have leak detection included in my test cases (Google mock/test). O
by PatKelly 11y ago
I develop applications in C++ on Linux and Windows. On windows I can enable heap tracing and have leak detection included in my test cases (Google mock/test). On Linux I need to run my app under Valgrind for leak checking as a separate process.
- michael_h 11y agoClang has a leak detector: http://clang.llvm.org/docs/LeakSanitizer.html http://clang.llvm.org/docs/LeakSanitizer.html It also has an address sanitizer that checks for out of bounds errors. I have found both to be enormously useful.
- padenot 11y agoYou want to make ASAN builds (simply build with clang or gcc > 4.8 with -fsanitize=address on the command line). Then you can break in a debugger, and do some tricks, explained in this page: https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAndDebugger https://code.google.com/p/address-sanitizer/wiki/AddressSani.... This will also detect any memory trashing or the like, while being quite fast (compared to valgrind, of course). Then if things are really weird, you can use valgrind.