Solved

VS2010 C++ Memory Leak detection software

Posted on 2011-02-25
5
1,296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

749 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