为什么windows内存诊断(Windows 内存诊断)

专注分享Linux后台服务器开发,包括C/C++,Linux,Nginx,Skynet,ZeroMQ,MySQL,Redis,fastdfs,MongoDB,ZK,流媒体服务器,CDN,P2P,K8S,Docker,TCP/IP,协程,DPDK等等技术,文末有资料福利包!

【C/C++基础进阶系列】实战记录 -- 内存泄漏检测相关总结

【1】Windows 下基于 VS2019 的内存泄漏检测1. 下载安装 VLD 内存泄漏检测工具

VLD 下载链接详见 VLD 下载地址

2. VS 2019 配置 VLD

加入 VLD 头文件与库路径

工程右键 “属性”–>“配置属性”->“VC++目录”–>“包含目录” 添加 VLD 的头文件目录

工程右键 “属性”–>“配置属性”->“VC++目录”–>“库目录” 添加 VLD 的库文件目录

使用 VLD 在项目中包含 vld.h 头文件即可检测项目中的内存泄漏情况,注意 VLD 只能在 Debug 模式下使用,VS 2019 需要开启生成调试信息相关的配置;

3. VLD 配置文件设置如下配置可以指定 VLD 输出文件并且在屏幕与文件中显示信息VLD 的配置文件应该放在运行程序同一个目录下

; Sets the report file destination, if reporting to file is enabled. A relative; path may be specified and is considered relative to the process' working; directory.;; Valid Values: Any valid path and filename.; Default: .\memory_leak_report.txt;ReportFile = .\memory_leak_report.txt ; Sets the report destination to either a file, the debugger, or both. If; reporting to file is enabled, the report is sent to the file specified by the; ReportFile option.;; Valid Values: debugger, file, both; Default: debugger;ReportTo = both