Is there a way to show memory leaks report in a C++ application using Visual Studio Code?
Perhaps a certain library? An extension? Using MinGW compiler?
I'm using Visual Studio Code (1.41.1) on Windows 10 with C++ extension (0.26.3). I've configured VS Code with MSVC compiler toolset (2019) as written in Configure VS Code for Microsoft C++. However I'm unable to show memory leaks using the CRT library, as written in Find memory leaks with the CRT library. My simple example code:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <iostream>
int main() {
printf("Hello world!\n");
int *a = new int;
*a = 8;
//delete a;
_CrtDumpMemoryLeaks();
return 0;
}
Using this code I cannot see any report generated by _CrtDumpMemoryLeaks()
.
When debugging the code it seems that the compiler skips the line _CrtDumpMemoryLeaks();
entirely.
Am I doing something wrong?
I've tried changing the configurations with _DEBUG=1
define, however the compiler even skips a #ifdef _DEBUG
statement.