Detected memory leaks

前端 未结 5 1722
天涯浪人
天涯浪人 2021-01-30 18:32

In my wxWidgets application, while running in debug mode i got this message in Output of Visual Studio 2010. The application ran fine, and i only saw this after closing it.

5条回答
  •  南方客
    南方客 (楼主)
    2021-01-30 19:18

    You just have to add the following lines at the beginning of your main function. Adding this flag, Visual Studio will break at the line that is creating the memory leak.

        _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
        _CrtSetBreakAlloc(9554);
        _CrtSetBreakAlloc(9553);
        _CrtSetBreakAlloc(9552);
    

    Make sure you have the correct object normal block address because they might change and ensure you are compiling on _DEBUG.

    See also: _CrtSetDbgFlag and _CrtSetBreakAlloc.

提交回复
热议问题