STL set 容器内存泄漏(WTL)
云满笔记 2013-08-14 07:59:03 为什么下面定义的那个m_aWindows会造成内存泄漏,不明白啊,有哪位大神知道的吗?我试过了,用vector不会提示泄漏,但是用set就会,好像map也会, 这该怎么办啊,是误报还是什么的,求大神路过啊,这真的需要大神来解答呀,我问了好多人,包括工作好几年的他们都不知道呀,我们搞WTL的,对STL知道的少之又少啊
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to
// make the EXE free threaded. This means that calls come in on a random RPC thread.
// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
ATLASSERT(SUCCEEDED(hRes));
// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
::DefWindowProc(NULL, 0, 0, 0L);
AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls
hRes = _Module.Init(NULL, hInstance);
ATLASSERT(SUCCEEDED(hRes));
int nRet = Run(lpstrCmdLine, nCmdShow);
_Module.Term();
::CoUninitialize();
std::set<HWND> m_aWindows;
for (std::set<HWND>::iterator it = m_aWindows.begin(); it != m_aWindows.end(); it++)
{
delete *it;
}
m_aWindows.clear();
#if _DEBUG
_CrtDumpMemoryLeaks();
#endif
return nRet;
}