我使用Visual C++發現了一個非常有趣的內存泄漏檢測器。VIsual Memory Leak Detector的使用
http://www.codeproject.com/KB/applications/visualleakdetector.aspx
我嘗試一下,但不能做它的工作原理來檢測內存泄漏的代碼。
我正在使用MS Visual Studio 2008.我錯過了任何步驟?
#include "stdafx.h"
#include "vld.h"
#include <iostream>
void fun() {
new int[1000];
}
int _tmain(int argc, _TCHAR* argv[])
{
fun();
std::cout << "lead?" << std::endl;
getchar();
return 0;
}
輸出,當我在調試模式下運行是:
...
...
'Test.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_e6967989\msvcr80.dll', Symbols loaded.
'Test.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', Symbols loaded (source information stripped).
'Test.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcp90d.dll', Symbols loaded.
'Test.exe': Loaded 'C:\Program Files\Visual Leak Detector\bin\dbghelp.dll', Symbols loaded (source information stripped).
Visual Leak Detector Version 1.9d installed.
No memory leaks detected.
Visual Leak Detector is now exiting.
The program '[5468] Test.exe: Native' has exited with code 0 (0x0).