Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

johnnyBravo

How to test if there are any memory leaks from a program?

This topic is 5452 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''ve completed the graphic side of a dx wrapper, and i just want to make sure i havent left any memory leaks. How would i test this? (also if possibly there is anyway to tell anything left that needs to be cleaned up, eg pointers etc)

Share this post


Link to post
Share on other sites
Advertisement
For memory leaks of DirectX. If I didnot forget link with d3dx8dt.lib and d3d8.lib. After exit from program in Visual C++ output screen it showns memory leaks. Not only for memory leaks all errors and warnings are output. If you are not using VC in utilities directory run dbmon.exe. the outputs will be shown there.
(Also for DX9 add dt suffix to lib filename)

For C++ memory leaks

define
// The following macros set and clear, respectively, given bits

// of the C runtime library debug flag, as specified by a bitmask.

#ifdef _DEBUG
#define SET_CRT_DEBUG_FIELD(a) \
_CrtSetDbgFlag((a) | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))
#define CLEAR_CRT_DEBUG_FIELD(a) \
_CrtSetDbgFlag(~(a) & _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))
#else
#define SET_CRT_DEBUG_FIELD(a) ((void) 0)
#define CLEAR_CRT_DEBUG_FIELD(a) ((void) 0)
#endif


At the end of the program call the below.

SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF );

I''ve took it from MSDN tested and works welll

Share this post


Link to post
Share on other sites

  • 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!