我最近安裝了VLD,以在Visual Studio 2008中嘗試和調試C++ MDI MFC應用程序.VLD報告了內存泄漏,無論我做了什麼我都無法解決問題,所以我創建了一個全新的空白項目(MDi MFC),內存泄漏仍然顯示出來。我所做的唯一修改是在主文件Project.h
中寫入#include <vld.h>
。文檔說哪個文件並不重要,所以這裏是執行後的輸出(只需選擇File/Exit,然後別的什麼都不做)。視覺泄漏檢測器檢測新的空白MFC項目上的泄漏
'Project.exe': Loaded 'C:\Users\MasterHD\Documents\Visual Studio 2008\Projects\Project\Debug\Project.exe', Symbols loaded.
'Project.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'Project.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugmfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_9b54853441e399d5\mfc90ud.dll', Symbols loaded.
'Project.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcr90d.dll', Symbols loaded.
'Project.exe': Loaded 'C:\Windows\SysWOW64\user32.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\msimg32.dll'
'Project.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\comctl32.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll'
'Project.exe': Loaded 'D:\Program Files (x86)\Visual Leak Detector\bin\Win32\vld_x86.dll'
'Project.exe': Loaded 'D:\Program Files (x86)\Visual Leak Detector\bin\Win32\dbghelp.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll'
'Project.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.mfcloc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_49768ef57548175e\MFC90ENU.DLL', Binary was not built with debug information.
Visual Leak Detector Version 2.4RC2 installed.
'Project.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll'
'Project.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll'
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 981 at 0x005BF560: 48 bytes ----------
Leak Hash: 0x32D8578B, Count: 1, Total 48 bytes
Call Stack (TID 9552):
f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c (159): MSVCR90D.dll!_malloc_dbg
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxmem.cpp (407): mfc90ud.dll!operator new + 0x16 bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxmem.cpp (61): mfc90ud.dll!operator new + 0x13 bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\tooltip.cpp (479): mfc90ud.dll!CWnd::FilterToolTipMessage + 0x11 bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\tooltip.cpp (374): mfc90ud.dll!CWnd::_FilterToolTipMessage
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp (1070): mfc90ud.dll!CWnd::PreTranslateMessage
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\barcore.cpp (372): mfc90ud.dll!CControlBar::PreTranslateMessage + 0xC bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp (2946): mfc90ud.dll!CWnd::WalkPreTranslateTree + 0x14 bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp (233): mfc90ud.dll!AfxInternalPreTranslateMessage + 0x12 bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp (777): mfc90ud.dll!CWinThread::PreTranslateMessage + 0x9 bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp (252): mfc90ud.dll!AfxPreTranslateMessage + 0x11 bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp (178): mfc90ud.dll!AfxInternalPumpMessage + 0x18 bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp (900): mfc90ud.dll!CWinThread::PumpMessage
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp (629): mfc90ud.dll!CWinThread::Run + 0xD bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\appcore.cpp (865): mfc90ud.dll!CWinApp::Run
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\winmain.cpp (47): mfc90ud.dll!AfxWinMain + 0xD bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\appmodul.cpp (30): Project.exe!wWinMain
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (574): Project.exe!__tmainCRTStartup + 0x35 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (399): Project.exe!wWinMainCRTStartup
0x76D8338A (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77719F72 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
0x77719F45 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
Data:
2C 00 00 00 00 00 00 00 F2 19 BA 00 00 E1 00 00 ,....... ........
00 00 00 00 00 00 00 00 18 00 00 00 17 00 00 00 ........ ........
00 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 ........ ........
Visual Leak Detector detected 1 memory leak (1016 bytes).
Largest number used: 14482 bytes.
Total allocations: 1681878 bytes.
Visual Leak Detector is now exiting.
The program '[14684] Project.exe: Native' has exited with code 0 (0x0).
任何人有任何見解或建議?我甚至無法確定是什麼導致內存泄漏,更不用說在我的實際項目中。
編輯:如果我關閉在右上角使用「X」,然後NO發生內存泄漏的應用程序,但是當我使用的文件/退出下拉菜單,它總是顯示1016字節泄露。
我不能說這個內存泄漏是否是誤報,但我可以說,我也得到完全相同的_same_泄漏消息時使用VS2005(sames路徑,不同的行號因爲我仍在使用mfc80ud.dll)和從codeplex站點獲得的_latest_版本的VLD(v2.4rc2)。使用v2.3時,泄漏不會出現。 –