static CObArray memory leaking

  • Thread starter Thread starter KeanHeng
  • Start date Start date
K

KeanHeng

Guest
Guys...


when exiting the program, Visual Studio gives out this

Detected memory leaks!
Dumping objects ->
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(188) : {71560} normal block at 0x12BAA240, 350 bytes long.
Data: < ux M > B4 A6 75 78 08 01 00 00 4D 01 00 00 01 00 00 00

d:\project\HelloWorld\control\myClassPage.cpp(1265) : {70621} client block at 0x12BA87A0, subtype c0, 24 bytes long.
a CObject object at $12BA87A0, 24 bytes long

LIne 1265 which point to the gcnew

I use this

m_arObjID[nLabel].Add(new CSomeData());
static CObArray m_arObjID[2];

Please help.......

How to clear up properly and where to clear? I tried this on destructor but will encounter memory exception, program will auto-call destructor from time to time (don't know why), whilst program is still running.



m_arObjID[nLabel].Add(new CSomeData());


~CSomeData()

for(int nLabel=0 ; nLabel<2; nLabel++)
{
for (int i = 0; i < m_arObjID[nLabel].GetCount(); i++)
{
CSomeData*& pInfo = (CSomeData*&)m_arObjID[nLabel].ElementAt(i);
delete pInfo;
}
m_arObjID[nLabel].RemoveAll();
}

// delete[] &m_arObjID; // will cause memory violation exception

Continue reading...
 
Back
Top