Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97327

Finding memory leaks in a C++ application with VS Code

$
0
0

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.


Viewing all articles
Browse latest Browse all 97327

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>