Original Post
Hi!
Every one is talkin about memory leaks if your not careful with memory alocaiton and deallocation. So i have always wondered how can you notice if your game leaks memory?
#ifdef _DEBUG
#include <crtdbg.h>
#define new new(_NORMAL_BLOCK,__FILE__, __LINE__)
#endif
And then in your main or WinMain function, put this:
#ifndef NDEBUG
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); // Get current flag
flag |= _CRTDBG_LEAK_CHECK_DF; // Turn on leak-checking bit
_CrtSetDbgFlag(flag); // Set flag to the new value
#endif
quote:
Original post by Anthracks
First, include this either at the top of the files you want to check for leaks, or in another header file that is included in everything.
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more