DirectShow IGraphBuilder 反复创建释放,导致内存不断增大

#include
#include
#include
#include
#include
#include
#include
#include

using namespace std;

int main(int argc, char *argv[])
{

int index = 0;;

for (;
{
if (index == 20000)
{
// break;
}
cout << index++ << endl;

CoInitializeEx(NULL, COINIT_MULTITHREADED);
//视频捕捉图形管理器接口
CComPtr pCaptureGraph; // Capture graph builder object
//图形管理器接口
CComPtr pGraph; // Graph builder object
HRESULT hr = pCaptureGraph.CoCreateInstance(CLSID_CaptureGraphBuilder2);
hr = pGraph.CoCreateInstance(CLSID_FilterGraph);
Sleep(30);
if ((pGraph))
{
(pGraph).Release();
(pGraph) = NULL;
}
if ((pCaptureGraph))
{
(pCaptureGraph).Release();
(pCaptureGraph) = NULL;
}
CoUninitialize();
cout << “Close” << endl;
}
return 0;
}

内存一直增加

没有找到directshow相关说明,采取折中方法解决此问题,采用单例方式,或者全局方式来使用directshow,将释放扔给进程来处理

你可能感兴趣的:(C++,directshow)