Re: DirectShow heap memory leak

From: Joe Flynn (joseph.flynn_at_nospam.nospam)
Date: 01/08/05


Date: Fri, 07 Jan 2005 18:44:43 -0600


Michael Schwab wrote:
> Working backwards is a great idea - here goes:
>
> - Already had the pVidWin stuff commented out.
> - Commented out the Run() and the infinite wait - still have the memory
> leak.
> - Commented out the Stop() and the RenderFile() - still have the memory
> leak.
> - Commented out the QueryInterface() for pControl and pEvent, and also their
> Release calls - still have the memory leak.
> - Commented out the CoCreateInstance() and pGraph->Release() calls - no more
> memory leak! (Not surprising because the CoInitialize wasn't using any heap
> space anyway, and that's all that was left).
> - Uncommented the CoCreateInstance() call but left the pGraph->Release()
> call commented out - now the memory doubles to 2.097 Mb, which is the amount
> that the CoCreateInstance() call usually takes.
>
> So for some reason the pGraph->Release() is only freeing up exactly half the
> space that CoCreateInstance() has allocated. And calling pGraph->Release()
> doesn't help, and sometimes crashes it (especially under WinXP).
>
> So what's wrong with my CoCreateInstance() call? Is it that pGraph is a
> local (stack?) variable?
>

What happens if you change the calls in question to:

      HRESULT hr = CoInitialize(NULL);
      CComPtr<IGraphBuilder> pGraph;
      CoCreateInstance(CLSID_FilterGraph,
                       NULL, CLSCTX_INPROC_SERVER,

                       IID_IGraphBuilder, (void **)&pGraph);
      CoUninitialize();



Relevant Pages


Loading