PDA

View Full Version : How to reduce momory in running image process



selvanathan
August 13, 2007, 16:11:13
Dear Sir,

I am using running image process in SDI,

in OnInitDialog() event i wrote

BOOL CDialog4::OnInitDialog()
{
CDialog::OnInitDialog();
m_pGrabber = new DShowLib::Grabber();
ASSERT( m_pGrabber );
m_pListener = new CListenerVTest();
ASSERT( m_pListener );

m_pGrabber->addListener( m_pListener, GrabberListener::eFRAMEREADY);
m_pSink = FrameHandlerSink::create( PIXEL_FORMAT, NUM_BUFFERS );
m_pSink->setSinkMode( GrabberSinkType::ePAUSE );
m_pGrabber->setSinkType( m_pSink );
CWnd* ImageWnd = GetDlgItem(IDC_LIVEIMAGE);
m_pGrabber->setHWND(ImageWnd->GetSafeHwnd());
RECT r;
ImageWnd->GetClientRect(&r);
m_pGrabber->setDefaultWindowPosition(false);
m_pGrabber->setWindowSize(r.right, r.bottom);

m_pGrabber->openDev("DFx 31AF03");
m_pGrabber->setVideoFormat("Y800 (1024x768)");
m_pGrabber->setFPS(30.00003);

__int64 iSerial;
m_pGrabber->getDev().getSerialNumber( iSerial );

m_pGrabber->startLive();

m_pSink->setSinkMode( GrabberSinkType::eRUN);

return TRUE;
}

because of this PF Usage(Page Memory) increases up to 45 MB

and it is also ok , but if i close the dialog, it will not reduces fully

on closing dialog i wrote following code

m_pSink->setSinkMode( GrabberSinkType::ePAUSE );
m_pGrabber->stopLive();
m_pGrabber->closeDev();
DeleteObject(m_pGrabber);
DeleteObject(m_pListener);

but it will reduce only 13 MB remaining memory not reduces,

for example before stating a program

PF MEMORY = 100

after open a dialog PF MEMORY = 145

after closing a dialog PF MEMORY = 132

and again i open a same dialog now PF MEMORY = 172

like this it increases every time when dialog opened
( after closing a project it reduces fully)

plz help me to clear maximum of memory

thanks in advance....

Sascha Schmidt
August 14, 2007, 11:58:24
Hallo selvanathan,

please write a small sample program, that shows the problem.

The first thing I see is that the Sink is not released.
So please write in the closing dialog:


m_pSink = Null;

In case that m_pSink is a smart pointer. Otherwise:


delete m_pSink;

selvanathan
August 16, 2007, 21:02:08
dear sir,
thank u for u r reply. after releasing sink memory reduced