How to disable Visual C ++ memory leak check for a specific file?

One of my projects is to use Microsoft memory leak check with _CrtSetDbgFlag , etc. This works fine, except that now I want to use a third-party package that misses a small amount of memory. I do not need to fix the leaks, but the result is annoying, as it masks the "real" leaks that can be introduced.

How can I disable this leak check for a specific file or project, but leave it to others? I understand that it is activated through some #define in debug mode - I had a little fiddle, but I could not find something that I can disable #undef .

+4
source share
1 answer

You can deactivate checking the placement of the heap in the corresponding files with _CrtSetDbgFlag () and the macro _CRTDBG_CHECK_DEFAULT_DF (which is 0 ) before the first new instruction in the file in which you do not want to check for memory leaks and respond to it immediately after the new instructions. See MSDN here .

Another way only for MFC projects : I personally use the DEBUG_NEW macro to detect memory leaks. In each file of my project, I added a macro. If you do not place the macro in a file, memory leaks will not be found in it, but only in others. The macro is explained here .

+4
source

All Articles