Solved

VS2010 C++ Memory Leak detection software

Posted on 2011-02-25
5
1,282 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sorting efficency of sorting algorithm 30 103
recursion example 16 111
I need an assist with a programming logic math question. 5 55
Advice in Xamarin 21 57
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

896 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

14 Experts available now in Live!

Get 1:1 Help Now