C++ 目视检漏仪未发现泄漏VS2013
我似乎无法让VLD捕捉任何内存泄漏,无论我如何尝试。你知道为什么吗 这里也是输出的一个片段:C++ 目视检漏仪未发现泄漏VS2013,c++,visual-studio,memory-leaks,visual-leak-detector,C++,Visual Studio,Memory Leaks,Visual Leak Detector,我似乎无法让VLD捕捉任何内存泄漏,无论我如何尝试。你知道为什么吗 这里也是输出的一个片段: Visual Leak Detector Version 2.4RC2 installed. The thread 0x5748 has exited with code 0 (0x0). The thread 0x2c70 has exited with code 0 (0x0). The thread 0x3c98 has exited with code 0 (0x0). No memory l
Visual Leak Detector Version 2.4RC2 installed.
The thread 0x5748 has exited with code 0 (0x0).
The thread 0x2c70 has exited with code 0 (0x0).
The thread 0x3c98 has exited with code 0 (0x0).
No memory leaks detected.
Visual Leak Detector is now exiting.
The program '[24988] ConsoleApplication2.exe' has exited with code 0 (0x0).
#包括
#包括
使用名称空间std;
班车{
公众:
Car(){}
汽车(字符串模型、整数年、字符串颜色){
本->型号=型号;本->颜色,本->年份=年份;
}
字符串getModel(){
返回此->模型;
}
void setModel(字符串m){
这个->模型=模型;
}
字符串getColor(){
返回此->颜色;
}
void setColor(字符串颜色){
这个->颜色=颜色;
}
空漆()
{
设置颜色(“白色”);
}
私人:
弦模型;
国际年;
字符串颜色;
};
int _tmain(int argc,_TCHAR*argv[]{
c车(“宝马”,2000年,“红色”);
c、 油漆();
cout它在visual studio 2013 ultimate下工作
您必须在控制台模式下执行程序(转到项目的调试目录)
在下面,您将看到结果的图片,但控制台显示了许多漏洞,我们无法在这里看到所有漏洞
我将include和lib路径添加到项目设置中
C:\ProgramFiles(x86)\VisualLeakDetector\include
C:\ProgramFiles(x86)\VisualLeakDetector\lib\win32
C:\ProgramFiles(x86)\VisualLeakDetector\lib\win64
如您所见,有13个内存泄漏
#include <vld.h>
#include <iostream>
using namespace std;
class Car{
public:
Car() {}
Car(string model,int year, string color) {
this->model = model; this->color, this->year = year;
}
string getModel() {
return this->model;
}
void setModel(string m) {
this->model = model;
}
string getColor() {
return this->color;
}
void setColor(string color) {
this->color = color;
}
void paint()
{
setColor("white");
}
private:
string model;
int year;
string color;
};
int _tmain(int argc, _TCHAR* argv[]){
Car c("bmw", 2000, "red");
c.paint();
cout << c.getColor().c_str();
for (int i = 0; i < 10; i++)
int *ptr = new int(10);
Car *c2 = new Car("benz", 2010, "yellow");
return 0;
}