Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Please recommend some tools for c++ static analysis and memory leak detecting

Reply
Thread Tools

Please recommend some tools for c++ static analysis and memory leak detecting

 
 
Brian Jiang
Guest
Posts: n/a
 
      12-21-2010
Hi every guru, could you please recommend some tools for C++ static
analysis and memory leak detecting.
It will be better if they are free of charge
 
Reply With Quote
 
 
 
 
Öö Tiib
Guest
Posts: n/a
 
      12-21-2010
On Dec 21, 3:04*pm, Brian Jiang <(E-Mail Removed)> wrote:
> Hi every guru, could you please recommend some tools for C++ static
> analysis and memory leak detecting.
> It will be better if they are free of charge


Most simple is perhaps to compile your code with different compilers
to get various diagnostics. Also there are several open source tools
like cppcheck, oink and flawfinder, but these are usually platform
specific and often produce false alerts.

MS prefast is perhaps best that is "free", but it is closed source,
windows specific and integrated into MS compiler. It is "free" since
for example their free driver development kit has such compiler in it
and you can get it to compile your (likely non-driver) code. Buying a
Visual Studio that features compiler with static analysis is not cheap
(nor "professional").

Then there is option to get AST out from compilers like g++ or CLang
and make analyzing queries yourself based on that. It is not little
work.

If you have budget for statical analysis then you can of course buy a
tool. Most commercial static code analysis tools for C++ are pretty
expensive with prices ranging $1 000 to $10 000 per license.
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      12-21-2010
On 12/21/2010 8:04 AM, Brian Jiang wrote:
> Hi every guru, could you please recommend some tools for C++ static
> analysis and memory leak detecting.
> It will be better if they are free of charge


Memory leak detectors are usually OS-specific, consider asking in the
newsgroup dedicated to your OS. There are also libraries that you can
build into your program that take over memory management, and they can
tell you whether/where you're have leaks. Sometimes that functionality
comes with the compiler itself, check your compiler manual.

Static analysis?... Code reviews by your team members are the best
thing. They aren't free, though, and usually only work with new code.
Which is to say, leave the old code alone. If you have indications that
it doesn't work, fix only what doesn't work. If you have no signs of
its malfunction, to statically analyze it is a waste of time.

V
--
I do not respond to top-posted replies, please don't ask
 
Reply With Quote
 
Virchanza
Guest
Posts: n/a
 
      12-21-2010
On Dec 21, 1:04*pm, Brian Jiang <(E-Mail Removed)> wrote:
> Hi every guru, could you please recommend some tools for C++ static
> analysis and memory leak detecting.
> It will be better if they are free of charge


To keep track of memory leaks, you could open up "stdlib.h" and
change it to use your own malloc & free functions that keep track of
memory allocations and deallocations. You could use the "atexit"
function to print a summary when the program ends.
 
Reply With Quote
 
AnonMail2005@gmail.com
Guest
Posts: n/a
 
      12-21-2010
On Dec 21, 8:04*am, Brian Jiang <(E-Mail Removed)> wrote:
> Hi every guru, could you please recommend some tools for C++ static
> analysis and memory leak detecting.
> It will be better if they are free of charge


google valgrind for a memory leak checker. It's for certain linux
platforms.

HTH
 
Reply With Quote
 
Brian Jiang
Guest
Posts: n/a
 
      12-23-2010
Thanks a lot everybody.
 
Reply With Quote
 
Brian Jiang
Guest
Posts: n/a
 
      12-23-2010
Thanks a lot everybody.
 
Reply With Quote
 
Katie
Guest
Posts: n/a
 
      12-25-2010
On Dec 21, 1:04*pm, Brian Jiang <(E-Mail Removed)> wrote:
> Hi every guru, could you please recommend some tools for C++ static
> analysis and memory leak detecting.
> It will be better if they are free of charge


Most memory leak detection software works at runtime rather than via
analysis. Valgrind and Purify are two good runtime tools.

Katie
--
CoderStack
http://www.coderstack.co.uk/c++-jobs
The Software Developer Job Board
 
Reply With Quote
 
DeMarcus
Guest
Posts: n/a
 
      12-26-2010
On 2010-12-21 14:04, Brian Jiang wrote:
> Hi every guru, could you please recommend some tools for C++ static
> analysis and memory leak detecting.
> It will be better if they are free of charge


Many has already pointed out Valgrind. Valgrind integrates well into the
Eclipse IDE and points out all occurrences of memory leaks directly in
the source code just like the compiler shows the errors. Pretty neat if
you like Eclipse.

 
Reply With Quote
 
Ramon F Herrera
Guest
Posts: n/a
 
      12-27-2010
On Dec 21, 7:04*am, Brian Jiang <(E-Mail Removed)> wrote:
> Hi every guru, could you please recommend some tools for C++ static
> analysis and memory leak detecting.
> It will be better if they are free of charge


This reminds me of a potential nightmare I faced recently, but gcc
came to my rescue.

The code in question is based on OpenCV and is supposed to run on
Windows and Linux:

IplImage *gray8 = crop(im, &cvRect(left,top,right-left+1,bottom-top
+1));

The Visual Studio compilers (all of 3):

(a) Did not warn me of the problem.
(b) Emitted code that crashed _inconsistently_ in some computers, not
in others.

Good ole' gcc provided a friendly warning and the dangerous code was
rewritten thusly:

CvRect region = cvRect(left,top,right-left+1,bottom-top+1);
IplImage *gray8 = crop(im, &region);

Profuse thanks to the bearded hackers in my old stomping grounds by
MIT.

-Ramon
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Building Static Analysis Tools for C++ Scott Meyers C++ 13 06-29-2011 09:12 PM
Evaluating static analysis and Dynamic analysis tools for C/C++ ssubbarayan C Programming 5 11-03-2009 12:50 AM
Blog: Tools for C++ Static Analysis Richard C++ 10 09-06-2009 03:15 PM
Any good static analysis tools out there? Derek C++ 2 03-04-2005 01:31 PM
Static Code Analysis Tools Don C Programming 1 07-25-2003 05:28 PM



Advertisments