Visual Studio CrtDumpMemoryLeaks Broken?
Visual Studio CrtDumpMemoryLeaks Broken?
我似乎在使用Visual Studio内置内存泄漏检测工具时遇到了问题。无论我做什么,它总是检测到内存泄漏。
这里我有一个基本的C++主,它启用了内存泄漏检测(根据MSDN)。
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
int main (){
_CrtDumpMemoryLeaks ();
return 0;
}
由于未知原因,它表示内存泄漏。
Detected memory leaks!
Dumping objects ->
{142} normal block at 0x0000005934F90660, 16 bytes long.
Data: < 3" > C8 33 22 DC F6 7F 00 00 00 00 00 00 00 00 00 00
Object dump complete.
其他人经历过这种情况吗?有人知道是什么原因造成的吗?
p.S我正在使用Visual Studio 2013,但我在2012年和2010年也经历过这种情况。
"_CrtDumpMemoryLeaks();"将显示执行时的内存状态,即您刚刚分配了一个内存块。
int main (){
std::string tmp("Hello");
_CrtDumpMemoryLeaks (); //this will show you have a memory leak (in the string object)
return 0;
}
使用
int main (){
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
std::string tmp("Hello");
return 0;
}
程序退出后,您将在"输出"窗口中找到调试输出。由于系统已删除字符串对象,因此没有内存泄漏。
如果您还包括
#ifdef _DEBUG
#define new new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#endif
首先,在所有代码文件中(或者首先是一个common.h文件),您将获得分配有问题内存的位置。
如果您重新定义了新的运算符,这将不起作用。
相关文章:
- P4Python p4.temp_client broken?
- 为什么 bash 在进程死后不打印"Broken pipe"日志?
- is compare_exchange_weak for std::shared_ptr broken in msvs
- Android NDK seekg broken?
- 在C++代码中重新启动连接时'Broken pipe'错误
- Visual Studio CrtDumpMemoryLeaks Broken?
- Netbeans:导航> 转到声明/定义 BROKEN 与 "Cannot Open Element" 在 C++ 64 位 Ubuntu 上
- C++ fwrite , ferror code 36 Broken Pipie
- Visual C++ 的两阶段模板实例化究竟Microsoft "broken"是什么?
- 使用 GSL 拟合分段"broken stick"模型