VS 2010中的内存泄漏检测问题 [英] problem for memory leak detection in VS 2010
本文介绍了VS 2010中的内存泄漏检测问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i定义uafxcwd.lib;项目设置中的LIBCMTD.lib,附加依赖性
我的项目是在VS2010中构建的。
现在我有找到内存泄漏的问题。因为通过添加此代码:
Hi,
i define uafxcwd.lib;LIBCMTD.lib in project settings, Additional dependency
my project is build in VS2010.
now i have problem to find memory leaks. because by adding this code:
#if defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
#define new DEBUG_NEW
#endif
我的项目将是错误:
my project will be errors:
void* __cdecl operator new(unsigned int .... already defined in ...
void* __cdecl operator delete(void*.... already defined in ...
推荐答案
请参阅我对该问题的评论。考虑使用其中一个内存调试器: http://en.wikipedia.org/wiki/Memory_debugger#List_of_memory_debugging_tools [ ^ ]。
-SA
Please see my comments to the question. Consider using one of the memory debuggers: http://en.wikipedia.org/wiki/Memory_debugger#List_of_memory_debugging_tools[^].
—SA
您添加的代码应该是:
The code you add should be:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#define new DBG_NEW
#endif
#endif // _DEBUG</crtdbg.h></stdlib.h>
仅在调试版本中有效。
http://msdn.microsoft.com/en-us/library/x98tx3cf(v = vs.100).aspx [ ^ ]
此链接页面底部还有注释。
Effective only in debug build.
http://msdn.microsoft.com/en-us/library/x98tx3cf(v=vs.100).aspx[^]
There are also comments at the bottom of this link page.
这篇关于VS 2010中的内存泄漏检测问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文