PDA

View Full Version : StartLive cause Handle leak



upen24931251
November 12, 2013, 10:04:35
Dear all:

I create a function SetCamera. Like this:

bool vlCamDev::SetCamera()
{
bool result = true;
unsigned int SetFlag = 0;
SuspendWatchDog();

if(ForceUpdate)
{
SetFlag = 0xFFFF;
}
else
{
// Set format
if(CamType & vlCMOS)
{
if( cdGetValue(Format, 0) )
SetFlag += vlFORMAT;
}

// Set FPS
if( cdGetValue(FPS, 1))
{
SetFlag += vlFPS;
}

// Binning factor
if( CamType & vlCMOS )
{
if( cdGetValue(Binning, 2) )
SetFlag += vlBIN;
}
else
DisableReg(XMLPara[2]);

// Gain
if( cdGetValue(Gain, 3) )
SetFlag += vlGAIN;

// Exposure
if( cdGetValue(ExpMode, 4) | cdGetValue(Exposure, 5) | cdGetValue(ExpRef, 6) )
SetFlag += vlEXP;

// White Balance
if(CamType & vlCOLOR)
{
if( cdGetValue(WBRed,7) | cdGetValue(WBGreen,8) | cdGetValue(WBBlue,9) )
SetFlag += vlWBALANCE;
}
else
{
DisableReg(XMLPara[7]);
DisableReg(XMLPara[8]);
DisableReg(XMLPara[9]);
}
}
if(SetFlag)
{
ForceUpdate = false;
if(SetFlag&vlFORMAT && !cdSetFormat())
return false;

if(SetFlag&vlFPS) result &= cdSetFPS();
if((pItems = grabber.getAvailableVCDProperties()) == 0)
{
printf("CAMERA: there is no available VCD property\n");
return false;
}
if(SetFlag&vlGAIN) result &= cdSetGain();
if(SetFlag&vlEXP) result &= cdSetExposure();
if(SetFlag&vlBIN && CamType&vlCMOS) result &= cdSetBinning();
if(SetFlag&vlWBALANCE && CamType&vlCOLOR) result &= cdSetWhiteBalance();
}

if( !grabber.isLive() ) {
grabber.startLive(false);
}

ResumeWatchDog();
return result;
}

Each time I call this function, it well cause Handle Leak.

After inspection, the leak cause by startLive().

I using "Process Explorer" to monitor the number of Handle and the number of Thread I've used.

After the statement of startLive(), the number of handle will increase about 14~17,

and the number of thread will increase 2.

The next time I call SetCamera, it won't free the resource I've used before,

and that cause the bigger Handle and Thread.

Question is how can I release these resource?

I've tried using stopLive(), but it doesn't work.

Please help me. Thx.

(PS: sorry for my poor English...)

Stefan Geissler
November 12, 2013, 12:00:31
Please let me know the IC Imaging Control Version, you use. Also the Windows and DirectShow version is helpful.

upen24931251
November 13, 2013, 01:04:43
1. I use the "ic3.3setup.exe" to install the Lib.

So I think the IC Imaging Control Version is 3.3

2. OS is Windows XP 32bit

3. The DirectShow, do you mean the DShowLib ?

Stefan Geissler
November 13, 2013, 11:59:29
3. The DirectShow, do you mean the DShowLib ?
Yes. You can use "DxDiag" tool to get the versions.

upen24931251
November 14, 2013, 01:11:37
Hi, I've solved this problem.

It's not cause by the StartLive function.

StartLive Function is fine.

Thank you!

Stefan Geissler
November 14, 2013, 08:19:18
Hi

good to read, that it is not the startlive.