6 ms·
Gotta have Valgrind suite in there somewhere. Useful to find use-after-free and loads of other issues. Plus cachegrind and the rest of the suite.
by lordnacho 7y ago
Gotta have Valgrind suite in there somewhere. Useful to find use-after-free and loads of other issues. Plus cachegrind and the rest of the suite.
- alfalfasprout 7y agoMassif + one of the visualizers is amazing for profiling allocations too.
- xyzzyz 7y agoThese days most people moved on from Valgrind to ASan and other sanitizers, which provide much of the same functionality with lower performance penalty.
- tomnj 7y agoValgrind's memcheck is still useful: it doesn't require recompiling, can handle external (binary-only) libraries, handles inline asm or jitted code, and provides uninitialized memory read instrumentation (yes, memsan does this, but it's tricky to set up). For me personally, I've required memcheck for applications using CUDA because CUDA and sanitizers don't play well together (for example, see https://github.com/google/sanitizers/issues/629 https://github.com/google/sanitizers/issues/629). but indeed, the sanitizers are soooo much faster :)
- pooya13 7y agoIs there a mem issue that can be caught by Valgrind but not by a compile time sanitizer?
- tomnj 7y agoSanitizers are not compile-time: they're runtime checks (aka dynamic analysis). For some strengths of valgrind compared to sanitizers, see my other comment in this thread.
- hermitdev 7y agoI love valgrind, but it falls on its face if you're dealing with more realtime aspects. In particular, dealing with high frequency trading systems. Valgrind, in of itself can through timings off in of itself to be unusable in some contexts. That said, great tool.
- mehrdadn 7y agoDo people use Valgrind much in C++? I've never had to. I feel like the only time I'd need it is if I'm writing "C++" code that is really just glorified C.
- mempko 7y agoUse it to profile my code, especially if you want to count cache misses, etc.
- tomnj 7y agoDue to the memory unsafety of C++, memory debuggers are absolutely used, including valgrind's memcheck and the Google sanitizers. Memory leaks and double frees are easier to avoid in C++ than C even without tooling, but use-after-free (for example) is absolutely a problem. And "modern" C++ won't necessarily help you here: even heard of string_view, span, or ranges? Memory debuggers are also often used in conjunction with fuzzing to track down bugs that the compiler may not tell you about.
- pjmlp 7y agoCan you say the same about the third party libraries or other in-house modules?
- de_watcher 7y agoStandard containers/algorithms/iterators have some caveats like messing up the erase-remove idiom by forgetting to pass the end iterator.
- deleted 7y ago[deleted]