求助:VLD检测内存泄漏时定位不到自己的代码
MFC程序,用最新的Visual Leak Detector (VLD) V2.2.3 检测内存泄漏,可以检测到有内存泄漏的地方,但是调用堆栈中全是系统的函数调用,没有显示在我代码的哪个文件/函数/行号等信息,如下:
---------- Block 5232 at 0x030C0328: 8 bytes ----------
Call Stack:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory (36): MFCTest.exe!std::_Allocate<std::_Container_proxy> + 0x15 bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory (187): MFCTest.exe!std::allocator<std::_Container_proxy>::allocate + 0xB bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring (469): MFCTest.exe!std::_String_val<wchar_t,std::allocator<wchar_t> >::_String_val<wchar_t,std::allocator<wchar_t> > + 0xA bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring (543): MFCTest.exe!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > + 0x5F bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility (163): MFCTest.exe!std::_Pair_base<CStdStr<wchar_t> const ,CStdStr<wchar_t> >::_Pair_base<CStdStr<wchar_t> const ,CStdStr<wchar_t> ><CStdStr<wchar_t> const &,CStdStr<wchar_t> &> + 0x76 bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility (195): MFCTest.exe!std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> >::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> ><CStdStr<wchar_t> const ,CStdStr<wchar_t> > + 0x55 bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory (208): MFCTest.exe!std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >::construct<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > &> + 0x3C bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory (281): MFCTest.exe!std::_Cons_val<std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >,std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> >,std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > &>
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtree (592): MFCTest.exe!std::_Tree_val<std::_Tmap_traits<CStdStr<wchar_t>,CStdStr<wchar_t>,std::less<CStdStr<wchar_t> >,std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >,0> >::_Buynode<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > &> + 0x2F bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtree (1521): MFCTest.exe!std::_Tree<std::_Tmap_traits<CStdStr<wchar_t>,CStdStr<wchar_t>,std::less<CStdStr<wchar_t> >,std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >,0> >::_Copy + 0x15 bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtree (1501): MFCTest.exe!std::_Tree<std::_Tmap_traits<CStdStr<wchar_t>,CStdStr<wchar_t>,std::less<CStdStr<wchar_t> >,std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >,0> >::_Copy + 0x1A bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtree (802): MFCTest.exe!std::_Tree<std::_Tmap_traits<CStdStr<wchar_t>,CStdStr<wchar_t>,std::less<CStdStr<wchar_t> >,std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >,0> >::operator=
c:\program files (x86)\microsoft visual studio 10.0\vc\include\map (150): MFCTest.exe!std::map<CStdStr<wchar_t>,CStdStr<wchar_t>,std::less<CStdStr<wchar_t> >,std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > > >::operator=
0x76773677 (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77669F42 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
0x77669F15 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
请问如何查看泄漏是对应到我自己代码的哪个地方呢?
---------- Block 5232 at 0x030C0328: 8 bytes ----------
Call Stack:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory (36): MFCTest.exe!std::_Allocate<std::_Container_proxy> + 0x15 bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory (187): MFCTest.exe!std::allocator<std::_Container_proxy>::allocate + 0xB bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring (469): MFCTest.exe!std::_String_val<wchar_t,std::allocator<wchar_t> >::_String_val<wchar_t,std::allocator<wchar_t> > + 0xA bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring (543): MFCTest.exe!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > + 0x5F bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility (163): MFCTest.exe!std::_Pair_base<CStdStr<wchar_t> const ,CStdStr<wchar_t> >::_Pair_base<CStdStr<wchar_t> const ,CStdStr<wchar_t> ><CStdStr<wchar_t> const &,CStdStr<wchar_t> &> + 0x76 bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility (195): MFCTest.exe!std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> >::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> ><CStdStr<wchar_t> const ,CStdStr<wchar_t> > + 0x55 bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory (208): MFCTest.exe!std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >::construct<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > &> + 0x3C bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory (281): MFCTest.exe!std::_Cons_val<std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >,std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> >,std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > &>
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtree (592): MFCTest.exe!std::_Tree_val<std::_Tmap_traits<CStdStr<wchar_t>,CStdStr<wchar_t>,std::less<CStdStr<wchar_t> >,std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >,0> >::_Buynode<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > &> + 0x2F bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtree (1521): MFCTest.exe!std::_Tree<std::_Tmap_traits<CStdStr<wchar_t>,CStdStr<wchar_t>,std::less<CStdStr<wchar_t> >,std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >,0> >::_Copy + 0x15 bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtree (1501): MFCTest.exe!std::_Tree<std::_Tmap_traits<CStdStr<wchar_t>,CStdStr<wchar_t>,std::less<CStdStr<wchar_t> >,std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >,0> >::_Copy + 0x1A bytes
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtree (802): MFCTest.exe!std::_Tree<std::_Tmap_traits<CStdStr<wchar_t>,CStdStr<wchar_t>,std::less<CStdStr<wchar_t> >,std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > >,0> >::operator=
c:\program files (x86)\microsoft visual studio 10.0\vc\include\map (150): MFCTest.exe!std::map<CStdStr<wchar_t>,CStdStr<wchar_t>,std::less<CStdStr<wchar_t> >,std::allocator<std::pair<CStdStr<wchar_t> const ,CStdStr<wchar_t> > > >::operator=
0x76773677 (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77669F42 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
0x77669F15 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
请问如何查看泄漏是对应到我自己代码的哪个地方呢?
...全文
相关推荐
Visual Leak Detector(VLD内存泄漏检测工具)支持VS2017
博客配套源码 VC++内存泄漏检测方法(3):Visual Leak Detector(VLD内存泄漏检测工具)支持VS2017 https://blog.csdn.net/libaineu2004/article/details/89763798
【C++内存泄漏】使用Visual Leak Detector(VLD)排查C++程序内存泄漏
本文详细介绍如何使用Visual Leak Detector排查内存泄漏问题。
使用vld进行内存泄漏检测的示例
VLD支持排查特定线程的泄漏、所有线程的泄漏、在特定的阶段启用泄漏检查,安装非常方便,从网站上下载安装包,安装即可(注意勾选集成到开发环境的选项) 安装完成后,需要做检测的地方,只要#include,即可启用内存泄漏检测了。
VLD内存泄漏检测
编译前包含LIB库,同时将vld.h and vldapi.h包含在stdafx.h之后,其他文件之前即可。具体看readme.txt
vld内存泄漏检测工具
vld内存泄漏检测工具,一款很不错的内存泄漏检测工具。


资源
