Solved

VS2010 C++ Memory Leak detection software

Posted on 2011-02-25
5
1,279 Views
Last Modified: 2012-05-11
I inherited a very large program, over 100K line, mixed with MFC C++ and native C codes. I am looking for a professional memory leak detection package. I just found the DevPartner and I am wondering is there anything better than that?  

My question is: "What is the best commercial memory leak detection software for the MFC C++ with VS2010?"   Cost is not an issue. I am looking for a package that can detect memory leak, both by scanning the code and reporting during the runtime.  It will be even better if it can suggest the code correction automatically.  

0
Comment
Question by:BaritoneH
  • 3
5 Comments
 
LVL 32

Expert Comment

by:phoffric
ID: 34983250
I used Parasoft C++ Insure++ program that literally savded a couple of projects. Given the quality of Ensure++, and their staying power in industry, I recommend them. And they will give you a free trial with technical support which will help you greatly.
    http://www.parasoft-embedded.com/products/insure.jsp
    http://www.parasoft.com/

Insure++ does much more than find memory leaks in real-time runs of your program.
    http://www.parasoft.com/jsp/products/slideshow/flash.jsp?popup=true&subdir=/products/support/presentation/flash/insure/Presentation7&ver=2&title=Insure

Parasoft also has an extensive automated Unit Test and System Regression Testing Suite which you may also be interested in if you are being saddled to maintain this 100K+ LOCs.
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 100 total points
ID: 34984505
Forget about "code scanning" - if that would work, the compiler would already warn you. One simple yet cost-efficiant way (in terms of 'no costs') would be to add the following to a central header file:

#ifdef _DEBUG
#ifndef _DBG_NEW

#include <crtdbg.h>

inline void* __operator_new(size_t __n) {
     return ::operator new(__n,_NORMAL_BLOCK,__FILE__,__LINE__);
}
inline void* _cdecl operator new(size_t __n,const char* __fname,int __line) {
     return ::operator new(__n,_NORMAL_BLOCK,__fname,__line);
}
inline void _cdecl operator delete(void* __p,const char*,int) {
     ::operator delete(__p);
}

#define _DBG_NEW new(__FILE__,__LINE__)
#define new _DBG_NEW


#endif // _DBG_NEW
#else

#define __operator_new(__n) operator new(__n)

#endif

Then, add

               int tmpFlag;

               // Get the current state of the flag
               // and store it in a temporary variable
               tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );

               // Turn On (OR) - Keep freed memory blocks in the
               // heap’s linked list and mark them as freed
               tmpFlag |= _CRTDBG_LEAK_CHECK_DF;

               // Set the new state for the flag
               _CrtSetDbgFlag( tmpFlag );


to your app's start code and call

               _CrtDumpMemoryLeaks ();


to before the program ends and you'll get the line number where the allocation occured.

(Ref.: http:Q_21009673.html)

Ohm and yes - the results are comparable to what e.g. BoundsChecker would report.
0
 
LVL 32

Expert Comment

by:phoffric
ID: 34984590
>> Forget about "code scanning" - if that would work, the compiler would already warn you.

If you are referring to the Insure++ product, then "code scanning" is the least important aspect. It is the dynamic run-time detection of memory issues that is of importance. You run the program, and it spits out memory issues.

BTW - I recall that the compilations with Insure++ did find many more problems than VC6.
0
 
LVL 12

Assisted Solution

by:trinitrotoluene
trinitrotoluene earned 100 total points
ID: 34985244
I would suggest you also give a try to Rational Purify

Purify

You can also evaluate PurifyPlus

0
 
LVL 32

Accepted Solution

by:
phoffric earned 300 total points
ID: 34985254
Yes, Purify. That is a competitor of Insure++. It went out of favor at my company in the early 90's when compared with Insure++; but since then, Purify was bought up by IBM, so perhaps, as part of the IBM "Rationale" line, it has improved.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now