Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

can't delete pBuilder- SampleCGB - causes memory leak

26 views
Skip to first unread message

Mechi

unread,
Feb 26, 2009, 3:39:57 AM2/26/09
to
hi!
I wrote a program based on Amcap and I use the SampleCGB.cpp,.h from
the SDK.
When i close down the application, I followed Amcap's TearDownGraph
and FreecapFilters, but the row "delete pBuilder" causes an access
violation in smartptr.h when trying to release graphBuilder2_ (which
is not NULL).

Here's the CloseCamera code:
pVSC[a_nCamNum-1].Release();
piBDR[a_nCamNum-1].Release(); // filter for BDR camera

if (pFilter[a_nCamNum-1]) // like gcap.Vcap in Amcap
NukeDownstream(pFilter[a_nCamNum-1], a_nCamNum);
if (pFilter[a_nCamNum-1])
pBuilder[a_nCamNum-1]->ReleaseFilters();
pFilter[a_nCamNum-1].Release();
pEvent[a_nCamNum-1].Release();
pControl[a_nCamNum-1].Release();
pGraph[a_nCamNum-1].Release();

if (pBuilder[a_nCamNum-1] != NULL)
{
//delete pBuilder[a_nCamNum-1];
pBuilder[a_nCamNum-1] = NULL;
}

The program works if the delete row is commented out - but causes
memory leaks.
What am I doing wrong?
Any ideas or suggestions?
Thanks!

Mechi

unread,
Feb 26, 2009, 9:40:35 AM2/26/09
to

Hi!
I added the row
graphBuilder2_.Release();

to the ReleaseFilters() function in SampleCGB.h.
Is this OK?
The delete pBuilder works, but i then get errors with other filters
that don't succeed being released.

Please help!
Mechi

rep_movsd

unread,
Feb 28, 2009, 8:51:21 AM2/28/09
to
Use smart com pointers, you cant go wrong...
Using raw ones is an abuse of C++

Mechi

unread,
Mar 1, 2009, 2:42:04 AM3/1/09
to
On Feb 28, 3:51 pm, rep_movsd <rep.mo...@gmail.com> wrote:
> Use smart com pointers, you cant go wrong...
> Using raw ones is an abuse of C++

I know - I tried using smart pointers, but I get an error
1>c:\program files\microsoft sdks\windows\v6.1\samples\multimedia
\directshow\common\smartptr.h(75) : error C2039: 'AddRef' : is not a
member of 'ISampleCaptureGraphBuilder'
1> c:\work\bec\capturefiltersample\samplecgb.h(44) : see
declaration of 'ISampleCaptureGraphBuilder'
1> c:\program files\microsoft sdks\windows\v6.1\samples
\multimedia\directshow\common\smartptr.h(70) : while compiling class
template member function 'SmartPtr<T>::SmartPtr(T *)'
1> with
1> [
1> T=ISampleCaptureGraphBuilder
1> ]
1> c:\work\bec\capturefiltersample\bdr_samplecodedlg.cpp
(49) : see reference to class template instantiation 'SmartPtr<T>'
being compiled
1> with
1> [
1> T=ISampleCaptureGraphBuilder
1> ]

Since I took the code (SampleCGB.cpp and .h) from the SDK, I though i
could use it as is.
Thanks!
Mechi

Mechi

unread,
Mar 1, 2009, 4:20:34 AM3/1/09
to
Used Amcap - first called Vivek's VirtualCamera (random clors on
screen) and then my filter (BDR Camera).
Both exited with errors (see below).
Has Anyone every seen this - how do I find the leaks? My filter is
based on Vivek's VCam (from TMH's site0 and my SampleGUI is based on
AmCap.
I've been trying to get the ISampleCaptureGraphBuilder (from
SampleCGB) to be used with smartpointers - but haven't succeeded.
Can anyone help?
Thanks!
Mechi

=====================================================================================
First-chance exception at 0x75f45e2d (devenum.dll) in AmCap.exe:
0xC0000005: Access violation reading location 0x00000000.
'AmCap.exe': Loaded 'C:\WINDOWS\system32\mslbui.dll', Symbols loaded
(source information stripped).
The thread 'COutputQueue::InitialThreadProc' (0x168c) has exited with
code 0 (0x0).
The thread 'Win32 Thread' (0x1004) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1f8) has exited with code 0 (0x0).
HEAP[AmCap.exe]: HEAP: Free Heap block d6d000 modified at d6d184 after
it was freed
Windows has triggered a breakpoint in AmCap.exe.

This may be due to a corruption of the heap, and indicates a bug in
AmCap.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information
The thread 'Win32 Thread' (0x1208) has exited with code 0 (0x0).
'AmCap.exe': Loaded 'C:\vcam\Bin\VCamD.ax', Symbols loaded.
The thread 'Win32 Thread' (0x1648) has exited with code 0 (0x0).
First-chance exception at 0x75f45e2d (devenum.dll) in AmCap.exe:
0xC0000005: Access violation reading location 0x00000000.
The thread 'Win32 Thread' (0x14fc) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x139c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x109c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1684) has exited with code 0 (0x0).
First-chance exception at 0x75f45e2d (devenum.dll) in AmCap.exe:
0xC0000005: Access violation reading location 0x00000000.
The thread 'Win32 Thread' (0x980) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xe18) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x440) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x300) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x964) has exited with code 0 (0x0).
Windows has triggered a breakpoint in AmCap.exe.

This may be due to a corruption of the heap, and indicates a bug in
AmCap.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information
vcamd.ax(tid 1640) 46129 :
vcamd.ax(tid 1640) 46129 : ID Object Description
vcamd.ax(tid 1640) 46129 :
vcamd.ax(tid 1640) 46129 : 3 (0012EBF8)
Virtual Cam
vcamd.ax(tid 1640) 46129 : 2 (0012EBF8)
Virtual Cam
vcamd.ax(tid 1640) 46130 :
vcamd.ax(tid 1640) 46130 : Total object count 2
'AmCap.exe': Unloaded 'C:\vcam\Bin\VCamD.ax'
Windows has triggered a breakpoint in AmCap.exe.

This may be due to a corruption of the heap, and indicates a bug in
AmCap.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information
BECfilter.ax(tid 1640) 61263 :
BECfilter.ax(tid 1640) 61263 : ID Object Description
BECfilter.ax(tid 1640) 61263 :
BECfilter.ax(tid 1640) 61263 : 143 (0012EBF8)
BDR Camera
BECfilter.ax(tid 1640) 61263 : 142 (0012EBF8) BDR
BEC Camera
BECfilter.ax(tid 1640) 61263 : 3 (0012EBF8)
BDR Camera
BECfilter.ax(tid 1640) 61263 : 2 (0012EBF8) BDR
BEC Camera
BECfilter.ax(tid 1640) 61263 :
BECfilter.ax(tid 1640) 61263 : Total object count 4
'AmCap.exe': Unloaded 'C:\Work\BEC\BECfilter\Bin\BECfilter.ax'
'AmCap.exe': Unloaded 'C:\WINDOWS\system32\quartz.dll'
'AmCap.exe': Unloaded 'C:\WINDOWS\system32\qcap.dll'
'AmCap.exe': Unloaded 'C:\WINDOWS\system32\msvfw32.dll'
'AmCap.exe': Unloaded 'C:\WINDOWS\system32\devenum.dll'
The thread 'Win32 Thread' (0x1090) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1678) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x470) has exited with code 0 (0x0).
The program '[5712] AmCap.exe: Native' has exited with code 0 (0x0).


rep_movsd

unread,
Mar 23, 2009, 4:01:55 AM3/23/09
to
First of all, when we say "smart pointers" round here, we mean COM
smart pointers : CComPtr and CComQIPtr
SmartPtr<T> is something else....

If you get a heap corruption, you have some serious bug - you are
overwriting variables or buffers in the data segment. I suspect your
FillBuffer code is writing more data than can fit into the sample
buffer.....

Vivek

0 new messages