您的位置:首页 > 教育 > 培训 > 女生学动漫制作技术好就业吗_本土建站工作室_网络营销属于什么专业类型_竞价排名是什么

女生学动漫制作技术好就业吗_本土建站工作室_网络营销属于什么专业类型_竞价排名是什么

2024/10/5 19:11:55 来源:https://blog.csdn.net/ResumeProject/article/details/142634969  浏览:    关键词:女生学动漫制作技术好就业吗_本土建站工作室_网络营销属于什么专业类型_竞价排名是什么
女生学动漫制作技术好就业吗_本土建站工作室_网络营销属于什么专业类型_竞价排名是什么
  • Visual Leak Detector,这是一个用于检测C/C++程序内存泄漏的工具。它可以在开发Windows应用程序时发现并修复内存泄漏的问题。

安装VLD

  • https://kinddragon.github.io/vld/
  • https://github.com/KindDragon/vld
    在这里插入图片描述

运行程序

在项目中包含头文件
  • 项目中,通常需要在main.cpp或相应的入口点文件中包含vld.h头文件。这样可以在程序启动时初始化VLD。
// main.cpp 或者项目的入口文件
#include "vld.h"
链接VLD库
  • 如果你使用的是Visual Studio,可以在项目属性中进行如下操作:
  1. 右键打开项目属性页面 (PropertiesAlt + Enter)。
  2. 转到VC++目录 -> 包含目录 添加VLD库的位置。
  3. 转到VC++目录 -> 库目录添加VLD.lib所在目录位置。

在这里插入图片描述

#include "vld.h"  // 引入VLD头文件
#include <iostream>int main() {std::cout << "Starting program..." << std::endl;int* p = new int(5);  // 分配内存// delete p;             // 释放内存std::cout << "Program finished." << std::endl;return 0;
}
  • 构建并运行程序。VLD会在程序退出时报告内存泄漏情况。
“testvld.exe”: 已加载“C:\Users\audit\Documents\Visual Studio 2010\Projects\testvld\Debug\testvld.exe”,已加载符号。
“testvld.exe”: 已加载“C:\Windows\SysWOW64\ntdll.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\kernel32.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\KernelBase.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\msvcp100d.dll”,已加载符号。
“testvld.exe”: 已加载“C:\Program Files (x86)\Visual Leak Detector\bin\Win32\vld_x86.dll”,已加载符号。
“testvld.exe”: 已加载“C:\Windows\SysWOW64\msvcr100d.dll”,已加载符号。
“testvld.exe”: 已加载“C:\Windows\SysWOW64\advapi32.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\msvcrt.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\sechost.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\bcrypt.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\rpcrt4.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Program Files (x86)\Visual Leak Detector\bin\Win32\dbghelp.dll”,Cannot find or open the PDB file
Visual Leak Detector read settings from: C:\Program Files (x86)\Visual Leak Detector\vld.ini
Visual Leak Detector Version 2.5.1 installed.
线程 'Win32 线程' (0x3328) 已退出,返回值为 0 (0x0)。
线程 'Win32 线程' (0x2144) 已退出,返回值为 0 (0x0)。
线程 'Win32 线程' (0x29dc) 已退出,返回值为 0 (0x0)。
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 1 at 0x014248D8: 4 bytes ----------Leak Hash: 0xFDB1D2BB, Count: 1, Total 4 bytesCall Stack (TID 4060):MSVCR100D.dll!operator new()c:\users\audit\documents\visual studio 2010\projects\testvld\testvld\main1.cpp (7): testvld.exe!main() + 0x7 bytesf:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (555): testvld.exe!__tmainCRTStartup() + 0x19 bytesf:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (371): testvld.exe!mainCRTStartup()KERNEL32.DLL!BaseThreadInitThunk() + 0x19 bytesntdll.dll!RtlInitializeExceptionChain() + 0x6B bytesntdll.dll!RtlClearBits() + 0xBF bytesData:05 00 00 00                                                  ........ ........Visual Leak Detector detected 1 memory leak (40 bytes).
Largest number used: 40 bytes.
Total allocations: 40 bytes.
Visual Leak Detector is now exiting.
程序“[8448] testvld.exe: 本机”已退出,返回值为 0 (0x0)。

解决内存泄漏

  • 根据VLD提供的报告,检查代码中的内存分配和释放逻辑,以确保所有的newmalloc都有对应的deletefree调用。
#include "vld.h"  // 引入VLD头文件
#include <iostream>int main() {std::cout << "Starting program..." << std::endl;int* p = new int(5);  // 分配内存// delete p;             // 释放内存std::cout << "Program finished." << std::endl;return 0;
}
  • 输出:No memory leaks detected.
“testvld.exe”: 已加载“C:\Users\audit\Documents\Visual Studio 2010\Projects\testvld\Debug\testvld.exe”,已加载符号。
“testvld.exe”: 已加载“C:\Windows\SysWOW64\ntdll.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\kernel32.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\KernelBase.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\msvcr100d.dll”,已加载符号。
“testvld.exe”: 已加载“C:\Windows\SysWOW64\msvcp100d.dll”,已加载符号。
“testvld.exe”: 已加载“C:\Program Files (x86)\Visual Leak Detector\bin\Win32\vld_x86.dll”,已加载符号。
“testvld.exe”: 已加载“C:\Windows\SysWOW64\advapi32.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\msvcrt.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\sechost.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\bcrypt.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Windows\SysWOW64\rpcrt4.dll”,Cannot find or open the PDB file
“testvld.exe”: 已加载“C:\Program Files (x86)\Visual Leak Detector\bin\Win32\dbghelp.dll”,Cannot find or open the PDB file
Visual Leak Detector read settings from: C:\Program Files (x86)\Visual Leak Detector\vld.ini
Visual Leak Detector Version 2.5.1 installed.
线程 'Win32 线程' (0xcd0) 已退出,返回值为 0 (0x0)。
线程 'Win32 线程' (0x3ca0) 已退出,返回值为 0 (0x0)。
线程 'Win32 线程' (0x3738) 已退出,返回值为 0 (0x0)。
No memory leaks detected.
Visual Leak Detector is now exiting.
程序“[10956] testvld.exe: 本机”已退出,返回值为 0 (0x0)。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com