Visual Leak Detector 在VS2013中无法检测到内存泄漏

6
我尝试了各种方法,似乎无法使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 leaks detected.
Visual Leak Detector is now exiting.
The program '[24988] ConsoleApplication2.exe' has exited with code 0 (0x0).


#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;
 }

我错过了什么?
1个回答

4

它是在Visual Studio 2013 Ultimate下运行的。

您必须以控制台模式执行程序(转到项目的调试目录)。

接下来,您将找到结果的图片,但控制台显示了许多泄漏,我们无法在此处看到所有泄漏。

我已将包含和库路径添加到项目设置中:

  1. C:\Program Files (x86)\Visual Leak Detector\include
  2. C:\Program Files (x86)\Visual Leak Detector\lib\win32
  3. C:\Program Files (x86)\Visual Leak Detector\lib\win64

enter image description here

正如您所看到的,有13个内存泄漏。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接