Original Post
I search for a quick and easy solution to find memory leaks, without the need to change much (or any) of the code. Something like mcheck.h for windows. Any ideas?
#ifndef MEMCHECK_H#define MEMCHECK_H#if defined( _MSC_VER ) // Visual Studio only#define _CRTDBG_MAP_ALLOC#include <stdlib.h>#include <crtdbg.h>#define new DEBUG_NEW#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )// Add in main():// _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );#endif // _MSC_VER#endif // MEMCHECK_HQuote:
Original post by Nypyren
There are a bunch of free solutions available if you search.
...#ifndef MEMCHECK_H#define MEMCHECK_H#if defined( _MSC_VER ) // Visual Studio only#define _CRTDBG_MAP_ALLOC#include <stdlib.h>#include <crtdbg.h>#define new DEBUG_NEW#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )// Add in main():// _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );#endif // _MSC_VER#endif // MEMCHECK_Hint main ( int argc, char** argv ){ _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );..._CRTDBG_ALLOC_MEM_DF' was not declared in this scope
main.cpp:37: error: _CRTDBG_LEAK_CHECK_DF' was not declared in this scopeQuote:
Original post by philipptr
I'm using g++ and cant seem to get that example to work:
Quote:
#if defined( _MSC_VER ) // Visual Studio only
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