0

I am analyzing a memory dump created by debugdiag. It shows CreateErrorinfo method call which leads to memory leak like below,

I am using proper map files for mydll and myanotherdll both. What is the meaning of CreateErrorInfo ? how it's leading to memory leak?

Function Source Destination mfc90u!operator new+33
mfc90u!CPlex::Create+1f mfc90u!operator new kernel32!TlsSetValueStub
kernel32!TlsSetValueStub
MYANOTHERDLL!CreateErrorInfo+188e2
MYDLL!MyClas::OnTimer+a3 ......\myfile.cpp @ 4639
MYDLL!CMainFrame::OnTimer+71 ......\mainfrm.cpp @ 1246
mfc90u!CWnd::OnWndMsg+407
mfc90u!AfxCallWndProc+a3
user32!MDIClientWndProcW
mfc90u!__sse2_available_init+657b
mfc90u!CWnd::WindowProc+24
mfc90u!AfxCallWndProc+a3
mfc90u!AfxWndProc+37 mfc90u!AfxCallWndProc mfc90u!AfxWndProcBase+56 mfc90u!AfxWndProc mfc90u!AfxWndProcBase

srajeshnkl
  • 883
  • 3
  • 16
  • 49
  • 2
    Show us the code of MyClas::OnTimer. Maybe you don't free the interface pointer you get. – xMRi Apr 22 '14 at 07:26

2 Answers2

2

Is this related to not releasing an interface? Interface from CreatorErroInfo must be released by client:

ICreateErrorInfo* pErrorInfo = nullptr;
HRESULT hr = ::CreateErrorInfo(&pErrorInfo);

if (pErrorInfo)
{
   pErrorInfo->Release();
}

Even better to use ATL's smart pointers:

CComPtr<ICreateErrorInfo> ptrErrorInfo;
HRESULT hr = ::CreateErrorInfo(&ptrErrorInfo);

if (ptrErrorInfo)
{
   //no release necessary
}
gast128
  • 1,223
  • 12
  • 22
0

CreateErrorInfo creates an instance of a generic error object.

This function returns a pointer to a generic error object, which you can use with QueryInterface on ICreateErrorInfo to set its contents. I believe you should check the state of ICreateErrorInfo pointer for more details in your code.

DNamto
  • 1,342
  • 1
  • 21
  • 42