Jump to content
  • Advertisement
Sign in to follow this  
TAkAw

Inexpensive alternitive to commercial error detection

This topic is 4828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was just wondering if a good error/resource leak detection tool is available that is similar to the commercial tools like Purify, and Boundschecker, cause who has $1000 to lay down on an app?

Share this post


Link to post
Share on other sites
Advertisement
When in c++, I do this:


#include <crtdbg.h>

using namespace std;

#ifdef _DEBUG
// new has 5 overloads. this one takes
// size_t, int const char*, int. size_t is filled
// in automatically by the compiler.
#define new new(_NORMAL_BLOCK,__FILE__,__LINE__)
#endif

void main(void)
{
// do some stuff for debug mode
#ifdef _DEBUG
// get current flags
int tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);

// don't free the blocks
tmpDbgFlag |= _CRTDBG_DELAY_FREE_MEM_DF;

// perform memory check for each alloc/dealloc
tmpDbgFlag |= _CRTDBG_CHECK_ALWAYS_DF;

// Perform automatic leak checking at program exit through
// a call to _CrtDumpMemoryLeaks and generate an error report
// if the application failed to free all the memory it allocated.
tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF;

_CrtSetDbgFlag(tmpDbgFlag);
#endif
// do main stuff here
}





It detects general memory leaks and the redefined new will tell you what file and line caused it. I'm sure it does nowhere near all the stuff the commercial programs do, but this is free and useful, and is in the standard library.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!