我想在我的代码,以控制MEM泄漏时编译错误。在我将头文件我已经添加以下代码:覆盖“新”
// You may need to locate mem leaks
#define ZEL_CHECK_MEMORY_LEAKS
#ifdef ZEL_CHECK_MEMORY_LEAKS
#define _CRTDBG_MAP_ALLOC
#include <cstdlib>
#include <crtdbg.h>
#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new (_NORMAL_BLOCK , __FILE__ , __LINE__)
#define new DBG_NEW
#endif
#endif // _DEBUG
#define zelInitMemoryCheck() \
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF)
#else
#define zelInitMemoryCheck()
#endif //ZEL_CHECK_MEMORY_LEAKS
如果我添加此代码,我得到这个编译错误:
1>c:\archivos de programa\microsoft visual studio 9.0\vc\include\xlocmon(283) : error C2061: syntax error : identifier '_DebugHeapTag_func'
1> c:\archivos de programa\microsoft visual studio 9.0\vc\include\xlocmon(281) : while compiling class template member function 'size_t std::moneypunct<_Elem,_Intl>::_Getcat(const std::locale::facet **,const std::locale *)'
1> with
1> [
1> _Elem=char,
1> _Intl=true
1> ]
1> c:\archivos de programa\microsoft visual studio 9.0\vc\include\xlocmon(908) : see reference to class template instantiation 'std::moneypunct<_Elem,_Intl>' being compiled
1> with
1> [
1> _Elem=char,
1> _Intl=true
1> ]
此外,在我的源代码我有这样的包容:
#include "core/zelCoreLib.h"
#include <boost/shared_ptr.hpp>
凡MEM泄漏控制代码为zelCoreLib.h
对于那些没有VC9.0这是代码“失败”
static size_t __CLRCALL_OR_CDECL _Getcat(const locale::facet **_Ppf = 0,
const locale *_Ploc = 0)
{ // return locale category mask and construct standard facet
if (_Ppf != 0 && *_Ppf == 0)
*_Ppf = _NEW_CRT moneypunct<_Elem, _Intl>(
_Locinfo(_Ploc->name()), 0, true);
return (_X_MONETARY);
}
它似乎是字符串和区域设施的一部分。此外,作为一个额外的信息,我使用Lua和LuaBind库
任何帮助将受到欢迎
你为什么不使用像现有的工具[VLD(http://sites.google.com/site/dmoulding/vld)? – 2011-05-06 09:03:43
这里绝对没有足够的继续。做一个_complete_,最小的测试用例。 – 2011-05-06 09:07:52
我已经做了一些简单的例子,一切都很好。只是在这一点上,我有这个错误。我可以插入我所有的日志库,但我可能会很过分。 – Killrazor 2011-05-06 09:16:56