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

4

2 に答える 2

2

これは、インターフェイスをリリースしないことに関連していますか? CreatorErroInfo からのインターフェイスは、クライアントによって解放される必要があります。

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

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

ATL のスマート ポインターを使用するとさらに効果的です。

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

if (ptrErrorInfo)
{
   //no release necessary
}
于 2015-10-27T09:04:51.637 に答える
0

CreateErrorInfo は、汎用エラー オブジェクトのインスタンスを作成します。

この関数は、一般的なエラー オブジェクトへのポインターを返します。これを ICreateErrorInfo の QueryInterface で使用して、その内容を設定できます。コードの詳細については、ICreateErrorInfo ポインターの状態を確認する必要があると思います。

于 2014-04-22T06:58:56.017 に答える