Ask Your Question

KFP's profile - activity

2012-11-18 11:51:05 -0600 commented question memory leak in loop

thx for your repply. switcing from cvCloneImage to cvCopy cleared the issue

2012-11-17 08:19:18 -0600 received badge  Editor (source)
2012-11-17 08:18:05 -0600 asked a question memory leak in loop

I'm using a simple for loop to do X itterations of the same filter:

void filterwrapper(IplImage *src, IplImage **dst, int filter_sel,
      int param1, int param2, int iterations) 
{
    int i;
    *dst = cvCloneImage(src);
    .
    .
    .
    for (i = 0; i < iterations; i++)
    {
        cvSmooth( *dst, *dst, CV_MEDIAN, param1, 0);
    }
}

I'm aware i somehow have to release the memory using cvReleasimg(), but doing so inside the loop causes my program to crash. I've tried using a temporary image (IplImage *tmp) as a placeholder and releasing this each loop, but i still get an memory allocation error when running the program.