BalaShiyamala / opencvdotnet

Automatically exported from code.google.com/p/opencvdotnet
0 stars 0 forks source link

Memory leaks when QueryFrame from JPEG #11

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create Capture with image as filename
2. CVImage frame = capture.QueryFrame();
3. frame.Release();

What is the expected output? What do you see instead?
frame has not been released, memory leak occurs.

What version of the product are you using? On what operating system?
0.7

Please provide any additional information below.
When doing capture.QueryFrame() which had been created by still image,
CVCapture.QueryFrame() will return "clone" instant of CVImage.

Which is:

CVImage^ Clone()
{
    CVImage^ n = gcnew CVImage(NULL);
    n->image = cvCloneImage(this->Internal);
    return n;
}

And as you see in CVImage.Release():

void Release()
{
    if (!created) return;

    IplImage* ptr = image;
    cvReleaseImage(&ptr);
}

since default value of "created" is true, your new cloning CVImage will not
 possible to release by cvReleaseImage!

You can fixing by modify CVImage.Clone() as following:

CVImage^ Clone()
{
    CVImage^ n = gcnew CVImage(NULL);
    n->image = cvCloneImage(this->Internal);
        n->created = true;
    return n;
}

Original issue reported on code.google.com by tanut...@gmail.com on 3 Mar 2008 at 3:17

GoogleCodeExporter commented 8 years ago
I got this problem too.
Modifying CVImage.Clone() caused huge heap of problems in other places.
My solution is quite simpler - to use

... = new CVImage(IPath);

instead of CVCapture

Original comment by Alexande...@gmail.com on 19 Mar 2008 at 10:49

GoogleCodeExporter commented 8 years ago
Hi,

I am also facing the same issue of memory leak with CvQueryFrame with 
opencv1.1.0 on
linux, Can you please guide me how to solve it on linux with opencv1.1.0

Thanks,
Smita

Original comment by smita.wa...@gmail.com on 30 Oct 2009 at 8:48