C++ dynamic review tools - c++

What's the best tool (commercial/open source) you've used for dynamic review/memory analysis of a C++ application?
EDIT: removed 'static' as there is already a great question on this topic (thanks Iulian!)

For dynamic memory analysis definitely Valgrind.

CPPCheck has served me well for a while now. This is for statical analysis.

Ryan, if you are on Windows and using MSVC++, then I can recommend BoundsChecker within DevPartner VC++ edition from Micro Focus. It has a feature within its memory tracking analysis called the Memory Resource Viewer. You use this to mark a point in time then look for allocations from that point forward. This plus the traditional heap corruption and other memory checks should help you dynamically track your C++ heap and stack issues. Shameless plug: I work on the DevPartner team. Look for DPS 10.5 with 64-bit support in BoundsChecker to launch February 4, 2011 at http://www.DevPartner.com.

Valgrind on Linux
Duma on Windows

For static code review KLOCWORKS is good.
For memory profiling, memory leaks identification, devpartner is a very good one.

Microsoft FxCop for static analysis (free). Parasoft Insure ($$$$) or IBM Purify ($$) for dynamic memory analysis.

Related

Dynamic code analysis for C++

Is there an open source and (relatively) simple-to-use dynamic code analysis tool for C++ code?
Something like IBM Purify (memory corruption detection, memory leak detection, application performance profiling, etc.)
The software that is widely used (on Linux at least) is Valgrind. It has a lot of sub tools used to do what you are looking for.
There is also KCacheGrind which is a GUI frontend to the profiling tool of Valgrind, AKA Cachegrind.
Try Duma (Detect Unintended Memory Access).
Try Valgrind. It is not as powerful as IBM Purify, but it works quite fine...
CodeCompass is quite good as well.
Although it has quite the dependencies compared to Valgrind and Duma, it's a quality analysis tool.

Which C++ Profiler to use?

I am supporting a C/Cpp application and have resolved few memory leak issues by creating objects. Since it is provided by the third party API, it is told that the objects gets destructed by the API itself.
I could manage to fix the issue and test my application without any issue. But i still doubt my fix for memory leak. I want to do profiling and i am in need of a Cpp tool that can tell me if there are chances of memory leaks in the code given a CPP file.
Is there a tool of that sort? Any help is greatly appreciated.
Thanks,
~Jegan
You are probably looking for a dynamic analysis tools, not a profile. For Linux, there's valgrind. For windows some good commercial solutions are Purify and Insure++.
Give valgrind a try, it's by far the best memory analysis tool I've come across. It only runs on *nix, but you haven't stated your platform.
We're using MemoryValidator from http://www.softwareverify.com/.
It provides a fully functional 30 day trial, so you can test it before buying.
Single license from 179$ (each for 10 licenses), up to 299$ (1 license). And it is really worth it's price. Enables you to find the cause for leaks within a minute.
Also check the other tools they're providing: performance validator, bug validator and so on.
Great tool once you know how to handle it :-)

Visual C++ - Memory Leak Detection

Any suggestions? This SO post talks about Visual Leak Detector, but I'm looking for other tools. Also, please don't recommend this.
I've used Visual Leak Detector quite recently and it works pretty well. It's very simple to build it in (just include vld.h) and doesn't require any instrumentation. I found that I needed to write a couple of scripts though to parse the output into something more useful for my purposes (it is crying out for a decent GUI). Note the new website -- the project is being actively maintained on Codeplex -- the Codeproject link is very old.
Try Deleaker or DevPartner, these both are good enough.
update:
C++ Memory Validator, works fine and fairly priced.
If you can afford some money use the Intel Parallel Inspector (https://www.intel.com/content/www/us/en/developer/tools/oneapi/inspector.html).
It doesn't require any code modifications and provides good reports.
I had to look for good tools to do that in work and that's the best tool (by far) that I found.
As suggested by Noah Roberts, i too felt Memory validator as the best tool for detecting leaks in Visual studio.
Purify also works.
Asked a similar question not long ago but related to 2010 specifically: VS2010 profiler/leak detection
If you're not using 2010 you might consider AQtime. It's not too terrible most the time. There are times thought when it fails to find an object related to the leak and just says "crt memory" or whatever.
Another I recently tried is called "Memory Validator". Not exactly a nice interface but it does seem to work, and work with 2010 too (just doesn't have any other kind of profiling in it, which is something I expect in a commercial tool like that).
Maybe GlowCode as was mentioned in other, similar questions, on SO when I searched before asking.
There is also application verifier. It can track a whole bunch of other issues as well apart from leaks like places where you forget to free win32 objects such as handles etc ...
The MSDN link is: http://msdn.microsoft.com/en-us/library/ms220948(VS.80).aspx
Jacob, the BoundsChecker tool inside DevPartner Studio contains two types of leak detectors for VC++. The uninstrumented version will tabulate leaks at process shutdown. The compile time instrumented detector will break on leaks at the time the leak occurrs showing both the current call stack at the point of leakage, and the allocation stack trace showing where the leaking memory was allocated. The 64-bit version of DPS and BoundsChecker 10.5 ships February 4, 2011 with x64 application support for Visual Studio 2010, 2008, and 2005. We also have a new pricing model so you can license just the BoundsChecker features and ugrade to the full DPS suite only if you find you need the other profilers or static analysis capabilities later on. Be sure to haggle with your sales rep too. Paying list price is like paying sticker price on a new car. Shameless plug: I work on the DevPartner team. DPS 10.5 represents my team's biggest release of tech capability since Compuware closed the NuMega lab. Please evaluate it for your own application and tech stack when 10.5 goes live. Cheers. Matt Schuetze, DevPartner Product Owner (and yes that means PO in normal Scrum team roles.)
VLD cannot be trusted for more serious projects.
Intel has a good tool called Inspector.
After 3 days searching for a good tool to find leaks on x64 binaries with C++ in Visual Studio, this is the only good option I found.
Try Dr.Memory.
They have proper visual studio integration and documentation is excellent.
Easy to use too.
https://sourceforge.net/projects/diagnostic/
http://diagnostic.sourceforge.net/index.html
I had tried so many memory leak detectors that it's difficult to count them all. Some of them crashed, some of them produced invalid results, some of them simply did not help. Eventually I've made my own leak detector, but invested so much effort into it - so made it non-free for time being. Managed / native / 32 & 64-bit architectures supported.
If you ever want to develop this tool further, please feel free to contact me.

Modern equivalent of BoundsChecker for Visual Studio 2008 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
In VS6 times there was BoundsChecker from Numega. I understand it is dead now, please correct me if I am wrong. What are the reliable alternatives? Preferably free or at least with trial version available.
IMO It might be a better idea to write custom memory manager (the one that supports new/delete/malloc/free wrappers). Make a new/delete wrapper that locks unused/freed memory using VirtualProtect (yeah, I know that default allocation block will have to be PAGE_SIZE bytes large, and you'll need a lot of ram even for a small app, but that's the only disadvantage). If you are on linux, it probably have VirtualProtect alternative. In this case any outrageous out-of-bounds access will generate access violation and will be easy to track. Also use stl containers when possible - they also offer bounds checking.
This advice is based on experience - I had worked with a terribly written huge (several megabytes of code) old software that had memory leaks, accessed already freed memory from multiple threads and so on. I've spent week trying different utilities (purify, devpartner studio, aqtime etc), and although some of them provided loads of information, none were really helpful. With custom memory managment problems were eliminated in 2 days (that includes writing memory manager).
If that doesn't work for you, try compuware devpartner studio - if it is still available anywhere.
BoundsChecker is certainly not dead. "It's only mostly dead, which means partly alive" (sorry, cannot resist the Miracle Max quote from The Princess Bride.) Seriously, BoundsChecker is alive and thriving under Micro Focus stewardship. We are releasing DevPartner Studio with 64-bit application support in BoundsChecker, the .NET/native/mixed performance and coverage profilers, and the .NET memory and holistic CPU/network/disk IO performance profiler. Look for DPS 10.5 to ship on February 4, 2011. The 10.5 release integrates seamlessly with Visual Studio 2005, 2008, and 2010, but you can still use BC standalone to run Active Check against VC6 and VC2003 binaries with some success if needed. Shameless plug: I work on the DevPartner team. I am peppering SO with notes announcing the newfound relevance of DPS 10.5 for C++ and .NET app dev troubleshooting on the x64 platform. With the new pricing model where you can license just BC or just the perf profiler, DPS should be much more accessible than it ever was under Compuware stewardship and lofty pricing. Disclaimer: these are my own opinions not necessarily sanctioned by Micro Focus.
Boundschecker is not dead. I'm using it with Visual Studio 2008.
They just changed owners (Compuware to MicroFocus, to Borland), now it's called DevPartner for Visual C++ BoundsChecker Suite
Check this:
http://www.borland.com/Products/Software-Testing/Automated-Testing/Devpartner-Studio
Bounds Checker used to be my second favorite tool, after a good debugger. I found it incredibly useful. Then it got so freakin expensive that I was no longer able to justify its purchase. If you want to know why hardly anybody even knows about this great tool anymore, there's your answer.
I also work for Micro Focus, and am the main guy right now for the BoundsChecker (DPS Error Detection) runtime internals. The product is definitely not dead, but the main thing keeping it alive right now is the fanatical loyalty of certain people. Though loyalty only goes so far. We continue to have customers. If the product weren't selling at all, the company would have laid us all off long ago and canned the product.
Anyway, for those of you with questions or bugs to report, try our forum at http://community.microfocus.com/.
Purify (Plus)
http://www-01.ibm.com/software/awdtools/purifyplus/
BoundsChecker was acquired multiple times and is now here: http://microfocus.com/products/DevPartner/BoundsCheckerSuite.asp
Another option is Rational Purify (Now owned by IBM): http://www-01.ibm.com/software/awdtools/purify/
Both of these products work, kinda. But neither are a silver bullet and bring with them a non-trivial amount of work to get useful information out of them. YMMV

C++ Code Profiler

Can anybody recommend a good code profiler for C++?
I came across Shiny - any good? http://sourceforge.net/projects/shinyprofiler/
Callgrind for Unix/Linux
DevPartner for Windows
Not C++ specific, but AMD's CodeAnalyst software is free and is feature-packed.
http://developer.amd.com/cpu/codeanalyst/codeanalystwindows/Pages/default.aspx
Gprof if you use gcc. It may not be user friendly but still useful.
Probably you will be interested in Intel VTune. Rather useful and allows to collect low-level events like cache misses which helps a lot in tuning.
Quantify (part of the IBM/Rational PurifyPlus package) is a very good profiler, but not exactly cheap. It is available on several platforms, too - I've used it on Solaris, Windows and Linux.
Depends on what you need to do:
Measure, so you can do regressions testing to see if changes in performance happened.
Find reasons for suboptimal performance and optimize them.
These are not the same.
For 1, use one of the recommended profilers.
For 2, the profiler I much prefer is one you already have:
http://www.wikihow.com/Optimize-Your-Program%27s-Performance
To see how this goes, check this out.
For C++, as for C# and any language that encourages layers of abstraction, those layers may or may not be good from a software engineering standpoint, but they can kill performance. Every method call is a detour in the execution of your program, and the style encourages you to nest those things, sometimes needlessly. Also the style discourages you from knowing or caring what goes on inside them. You may find them creating and deleting objects underneath at a rate and level of generality far beyond what your application really needs.
AQtime (for Windows)
If you are running a Premium version of VS 2010 then you get a profiler with it.
I've also used a couple of other free ones, but they don't compare to the on MS ships. Useful as a second opinion though.
If you have access to a Mac, then I recommend using Shark from the CHUD tools.
You can use the analyzer that´s in Sun Studio 12 on Linux or Solaris. Itś free. http://developers.sun.com/sunstudio/index.jsp
If you cannot locate DevPartner it is because we've moved under new ownership. Check us out on the Micro Focus website: http://www.microfocus.com/products/micro-focus-developer/devpartner/index.aspx. Shameless plug: I work on the DevPartner team. Our long awaited 64-bit versions of BoundsChecker and C++/.NET profilers ship on February 4, 2011. We've changed our pricing model so you can choose either the whole suite or just the performance profiler if that's what you need. Please check out the new DPS 10.5 release when it goes live!