Re: Memory leak in small video player application

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello,

Many thanks for your help. I use C++ Builder 5 from Borland and it seems that the use of CComPtr and CComQIPtr does not work under this environment.

My function is very simple and based on an example from the DX SDK, was there anything special I missed in the function that generates leaks, or will there always be leaks by using plain pointers and calling release on them ?

Best Regards,
Gaël

The March Hare [MVP] wrote:
On Mon, 16 Jan 2006 19:28:10 +0100, Gaël Rosset wrote:


I have made a small video player which in turns plays small video clips. The class soundvideoplayer contains among other things the following members :
IMediaEventEx *g_pEvent;
IGraphBuilder *pGraph;
IMediaControl *pControl;
IMediaEvent *pEvent;
IMediaSeeking *g_pSeek;
IBaseFilter *pFilter;
IBasicAudio *m_pBA;


To play the clips I call the function play below over and over again.
The problem is that even if I don't run the graph I am leaking memory by calling play in loops.


I am calling Release on all used interfaces... I feel blind about the issue.


The first thing to do is convert these and all other plain pointers to use
CComPtr and CComQIPtr.  It is madness to use plain pointers.  You can
release all of the pointers properly with smart pointers by using them in a
class and destroying that class or by using them in a method and exiting
that method.

.