当前位置: 首页 > 网络知识

Qt Visual Leak Detector 输出解析(四)

时间:2026-01-29 09:26:52

1. 使用方式

  在 QT 中使用 VLD 的方法可以查看另外几篇博客:

  本次测试使用的环境为:QT 5.9.2,Debug 模式,VLD 版本为 2.5.1,VLD 配置文件不做任何更改使用默认配置,测试工程所在路径为:E:\Cworkspace\Qt 5.9\QtDemo\testVLD。

2. 测试代码

  写一个有一处内存泄漏的程序,如下:

1 #include <QCoreApplication> 2 #include "vld.h" 3 4 void testFun() 5 9 10 int main(int argc, char *argv[]) 11

3. 使用 32 bit 编译器时的输出

  使用MSVC 2015 32bit编译器,程序运行时,在标准输出窗会输出以下结果:

ptr = 0070a3d0, *ptr = 55345678

  程序运行结束后,检测到了内存泄漏,VLD 会输出以下报告(本例中出现一处内存泄漏),第 1~3 行显示 VLD 运行状态,第 4~21 行显示泄漏内存的详细信息,第 22~24 行总结此次泄漏情况,第 25 行显示 VLD 退出状态。

1 Visual Leak Detector read settings fr: D:\Program Files (x86)\Visual Leak Detector\vld.ini 2 Visual Leak Detector Version 2.5.1 installed. 3 WARNING: Visual Leak Detector detected memory leaks! 4 Block 1 at 0x0070A3D0: 4 bytes 5 Leak Hash: 0xA7ED883D, Count: 1, Total 4 bytes 6 Call Stack (TID 20672): 7 ucrtbased.dll!malloc() 8 f:\dd\vctools\crt\vcstartup\src\heap\new_scalarpp (19): testVLD.exe!operator new() + 0x9 bytes 9 e:\cworkspace\qt 5.9\qtdemo\testvld\mainpp (6): testVLD.exe!testFun() + 0x7 bytes 10 e:\cworkspace\qt 5.9\qtdemo\testvld\mainpp (16): testVLD.exe!main() 11 f:\dd\vctools\crt\vcstartup\src\startup\exe_cmon.inl (74): testVLD.exe!invoke_main() + 0x1B bytes 12 f:\dd\vctools\crt\vcstartup\src\startup\exe_cmon.inl (264): testVLD.exe!__scrt_cmon_main_seh() + 0x5 bytes 13 f:\dd\vctools\crt\vcstartup\src\startup\exe_cmon.inl (309): testVLD.exe!__scrt_cmon_main() 14 f:\dd\vctools\crt\vcstartup\src\startup\exe_mainpp (17): testVLD.exe!mainCRTStartup() 15 KERNEL32.DLL!BaseThreadInitThunk() + 0x19 bytes 16 ntdll.dll!RtlGetAppContainerNamedObjectPath() + 0x11E bytes 17 ntdll.dll!RtlGetAppContainerNamedObjectPath() + 0xEE bytes 18 Data: 19 78 56 34 55 xV4U.... ........ 20 21 22 Visual Leak Detector detected 1 memory leak (40 bytes). 23 Largest number used: 40 bytes. 24 Total allocations: 40 bytes. 25 Visual Leak Detector is now exiting.

4. 使用 64 bit 编译器时的输出

  使用MSVC 2015 64bit编译器,程序运行时,在标准输出窗会输出以下结果:

ptr = 25a42da0, *ptr = 55345678

  程序运行结束后,检测到了内存泄漏,VLD 会输出以下报告(本例中出现一处内存泄漏),第 1~3 行显示 VLD 运行状态,第 4~21 行显示泄漏内存的详细信息,第 22~24 行总结此次泄漏情况,第 25 行显示 VLD 退出状态。

1 Visual Leak Detector read settings fr: D:\Program Files (x86)\Visual Leak Detector\vld.ini 2 Visual Leak Detector Version 2.5.1 installed. 3 WARNING: Visual Leak Detector detected memory leaks! 4 Block 1 at 0x0000000025A42DA0: 4 bytes 5 Leak Hash: 0x92ED96C9, Count: 1, Total 4 bytes 6 Call Stack (TID 16444): 7 ucrtbased.dll!malloc() 8 f:\dd\vctools\crt\vcstartup\src\heap\new_scalarpp (19): testVLD.exe!operator new() + 0xA bytes 9 e:\cworkspace\qt 5.9\qtdemo\testvld\mainpp (6): testVLD.exe!testFun() + 0xA bytes 10 e:\cworkspace\qt 5.9\qtdemo\testvld\mainpp (16): testVLD.exe!main() 11 f:\dd\vctools\crt\vcstartup\src\startup\exe_cmon.inl (75): testVLD.exe!invoke_main() 12 f:\dd\vctools\crt\vcstartup\src\startup\exe_cmon.inl (264): testVLD.exe!__scrt_cmon_main_seh() + 0x5 bytes 13 f:\dd\vctools\crt\vcstartup\src\startup\exe_cmon.inl (309): testVLD.exe!__scrt_cmon_main() 14 f:\dd\vctools\crt\vcstartup\src\startup\exe_mainpp (17): testVLD.exe!mainCRTStartup() 15 KERNEL32.DLL!BaseThreadInitThunk() + 0x14 bytes 16 ntdll.dll!RtlUserThreadStart() + 0x21 bytes 17 Data: 18 78 56 34 55 xV4U.... ........ 19 20 21 Visual Leak Detector detected 1 memory leak (56 bytes). 22 Largest number used: 56 bytes. 23 Total allocations: 56 bytes. 24 Visual Leak Detector is now exiting.

5. 输出报告对比结果

使用不同位数的编译器时,输出报告的差异主要体现在以下几点:



上一篇:Qt 常用数据类型转换
下一篇:Qt quint16 高低字节 quint8
Qt VisualLeakDetector
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器
  • 英特尔第五代 Xeon CPU 来了:详细信息和行业反应
  • 由于云计算放缓引发扩张担忧,甲骨文股价暴跌
  • Web开发状况报告详细介绍可组合架构的优点
  • 如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳
  • 美光在数据中心需求增长后给出了强有力的预测
  • 2027服务器市场价值将接近1960亿美元
  • 生成式人工智能的下一步是什么?
  • 分享在外部存储上安装Ubuntu的5种方法技巧
  • 全球数据中心发展的关键考虑因素
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器

    英特尔第五代 Xeon CPU 来了:详细信息和行业反应

    由于云计算放缓引发扩张担忧,甲骨文股价暴跌

    Web开发状况报告详细介绍可组合架构的优点

    如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳

    美光在数据中心需求增长后给出了强有力的预测

    2027服务器市场价值将接近1960亿美元

    生成式人工智能的下一步是什么?

    分享在外部存储上安装Ubuntu的5种方法技巧

    全球数据中心发展的关键考虑因素