VLD动态内存检测-vs2019配置

原创
2021/11/11 10:52
阅读数 880

工具下载、安装:
https://github-releases.githubusercontent.com/566097/583de30e-b359-11e7-99d7-0f1fb50d7654?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211111%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211111T020338Z&X-Amz-Expires=300&X-Amz-Signature=faeae18b589347b5a5a62b6b2b14584e6394207f06e147bde7ebd8f3b778a355&X-Amz-SignedHeaders=host&actor_id=59048253&key_id=0&repo_id=566097&response-content-disposition=attachment%3B%20filename%3Dvld-2.5.1-setup.exe&response-content-type=application%2Foctet-stream

vs2019配置:
vld include add
dll拷贝到bin目录下
vld link libpath add
vld.ini文件拷贝bin目录下并且修改

生成目录
ReportFile = .\memory_leak_report.txt
控制台和日志结果都显示
ReportTo = both

debug运行调试:
控制台出现
Visual Leak Detector read setting from:XXX
说明配置对了

关闭程序,查看总结果:21个内存泄漏
Visual Leak Detector detected 21 memory leaks (1156 bytes).
Largest number used: 1432 bytes.
Total allocations: 3244 bytes.
Visual Leak Detector is now exiting.

每一项结果:看到具体的文件函数可以查看到new的语句
---------- Block 62 at 0x000B5470: 4 bytes ----------
  Leak Hash: 0x2EC766ED, Count: 1, Total 4 bytes
  Call Stack (TID 218900):
    ucrtbased.dll!malloc()
    d:\a01\_work\2\s\src\vctools\crt\vcstartup\src\heap\new_scalar.cpp (35): SerialTest.exe!operator new() + 0x9 bytes
    E:\sourcecode\src\common\Tests\SerialTest\SerialTest.cpp (85): SerialTest.exe!InoComManagerTest() + 0x7 bytes
    E:\sourcecode\src\common\Tests\SerialTest\SerialTest.cpp (153): SerialTest.exe!main()
    d:\a01\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl (78): SerialTest.exe!invoke_main() + 0x2D bytes
    d:\a01\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl (288): SerialTest.exe!__scrt_common_main_seh() + 0x5 bytes
    d:\a01\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl (331): SerialTest.exe!__scrt_common_main()
    d:\a01\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): SerialTest.exe!mainCRTStartup()
    KERNEL32.DLL!BaseThreadInitThunk() + 0x19 bytes
    ntdll.dll!RtlGetAppContainerNamedObjectPath() + 0xED bytes
    ntdll.dll!RtlGetAppContainerNamedObjectPath() + 0xBD bytes
  Data:
    E0 3E 3E 01                                                  .>>..... ........

分析:
自行分析哪些是全局或者静态变量,哪些是动态需要释放的。
 

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部