2015-10-16 48 views
5

我似乎无法让VLD捕获任何内存泄漏,不管我尝试了什么。任何想法为什么?这里的输出片段也是如此:视觉泄漏检测器没有发现泄漏VS2013

我错过了什么?

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

回答

3

它的工作下的Visual Studio 2013最终

你有一个控制台模式执行程序(进入该项目的调试目录)

在下面,你会发现结果的图片,但是控制台显示了很多泄漏,我们在这里看不到所有的泄漏

我加入了包括和项目的lib路径设置

  1. C:\ Program Files文件(x86)的\视觉检漏仪\包括
  2. C:\ Program Files文件(x86)的\视觉检漏仪\ LIB \ WIN32
  3. C:\ Program Files文件(x86)的\视觉检漏仪\ LIB \ Win64的

enter image description here

正如你看到有是13内存泄漏。