问题描述
- 全局队列内存泄露问题
- #include ""stdafx.h""
#define _CRTDBG_MAP_ALLOC
#include<stdlib.h>
#include<crtdbg.h>#include <deque>
using std::deque;deque<int> des;
int _tmain(int argc _TCHAR* argv[])
{
_CrtDumpMemoryLeaks();
return 0;
}OUTPUT如下:
“123.exe”: 已加载“E:projectsLocoLibraryMgeDebug123.exe”,已加载符号。
“123.exe”: 已加载“C:WindowsSysWOW64ntdll.dll”,Cannot find or open the PDB file
“123.exe”: 已加载“C:WindowsSysWOW64kernel32.dll”,Cannot find or open the PDB file
“123.exe”: 已加载“C:WindowsSysWOW64KernelBase.dll”,Cannot find or open the PDB file
“123.exe”: 已加载“C:WindowsSysWOW64msvcp100d.dll”,已加载符号。
“123.exe”: 已加载“C:WindowsSysWOW64msvcr100d.dll”,已加载符号。
Detected memory leaks!
Dumping objects ->
{183} normal block at 0x003782D0 8 bytes long.
Data: < > A0 D1 A5 00 00 00 00 00
Object dump complete.
程序“[4984] 123.exe: 本机”已退出,返回值为 0 (0x0)。
解决方案
**#include ""stdafx.h""
#define _CRTDBG_MAP_ALLOC
#include
#include
#include
using std::deque;
deque des;
int _tmain(int argc _TCHAR* argv[])
{
_CrtDumpMemoryLeaks();
return 0;
}**
解决方案二:
#include ""stdafx.h""
#define _CRTDBG_MAP_ALLOC
#include<stdlib.h>
#include<crtdbg.h>
#include <deque>
using std::deque;
deque<int> des;
int _tmain(int argc _TCHAR* argv[])
{
_CrtDumpMemoryLeaks();
return 0;
}
解决方案三:
全局队列deque 初始化一下