我遇到内存泄漏问题。我有以下代码:
#include "StdAfx.h"
#include <Map>
typedef struct _OUTPUT_HANDLER
{
unsigned short outCnt;
_OUTPUT_HANDLER()
: outCnt(0)
{}
} OUTPUT_HANDLER, *POUTPUT_HANDLER;
typedef std::map<unsigned long, OUTPUT_HANDLER *>outDataMap;
outDataMap outData;
int _tmain(int argc, _TCHAR *argv[])
{
if (!outData.empty())
{
POUTPUT_HANDLER oHandler;
for (outDataMap::const_iterator dataOut = outData.begin(); dataOut != outData.end(); dataOut++)
{
oHandler = dataOut->second;
delete[] oHandler;
}
outData.clear();
}
_CrtDumpMemoryLeaks();
return 0;
}
当我运行它并到达_CrtDumpMemoryLeaks();行时我收到以下泄漏:
Detected memory leaks!
Dumping objects ->
{221} normal block at 0x0017B9E0, 24 bytes long.
Data: < > E0 B9 17 00 E0 B9 17 00 E0 B9 17 00 CD CD CD CD
{220} normal block at 0x0017B998, 8 bytes long.
Data: < 8 > A0 01 38 01 00 00 00 00
Object dump complete.
如果能解决此问题,我将不胜感激。