09-24-2008 08:18 AM
I suspect a memory leak in imaqFindPattern()
When I run this function in a loop the amount of RAM used by the program increases step by step. When I disable two statements in the loop, the amount of RAM used remains the same. The two lines that I toggle are:
pm=imaqFindPattern(input_image,ref_image,some_rect,&options,NULL,&n);
if(pm) imaqDispose(pm);
I added an 'else' to the 'if', but it is never executed.
It happens also when I use the same image every time in the loop.
I used NI Vision 8.6 and CV 8.01 on Windows XP.
Please confirm or help. 😉
Solved! Go to Solution.
09-24-2008 03:20 PM
10-06-2008 09:46 AM
These are the options:
// Init FindPattern Options
IPFindPatternOptions.angleRanges=NULL;
IPFindPatternOptions.minMatchScore=100;
IPFindPatternOptions.mode=IMAQ_MATCH_SHIFT_INVARIANT;
IPFindPatternOptions.numMatchesRequested=1;
IPFindPatternOptions.numRanges=0;
IPFindPatternOptions.showResult=FALSE;
IPFindPatternOptions.showSearchArea=TRUE;
IPFindPatternOptions.subpixelAccuracy=FALSE;
It's a little bit hard for me to attach pictures, because it is about checking passport images, so personal data is involved.
When I run the (very stripped) program below, I do not have a memory leak.
In my original program, when I comment the imaqFindPattern(...) statement there is no leak, when I include it, there is a memory leak.
I have tried the alternative with imaqLearnPattern(...) and imaqMatchPattern(...) but that also leaks.
Maybe someone knows about a good memory leak finder (if such exists)?
This is the program that does not leak:
#include <windows.h>
#include "nivision.h"
#include "nimachinevision.h"
static FindPatternOptions o;
// main
int main(int argc,char *argv[])
{
Image *SrcImg,*RefImg;
PatternMatch *pm;
int i,n;
SrcImg=imaqCreateImage(IMAQ_IMAGE_U8,0);
imaqReadFile(SrcImg,"SrcImg.png",NULL,NULL);
RefImg=imaqCreateImage(IMAQ_IMAGE_U8,0);
imaqReadFile(RefImg,"RefImg.jpg",NULL,NULL);
// Init FindPattern options
o.angleRanges=NULL;
o.minMatchScore=100;
o.mode=IMAQ_MATCH_SHIFT_INVARIANT;
o.numMatchesRequested=1;
o.numRanges=0;
o.showResult=TRUE;
o.showSearchArea=TRUE;
o.subpixelAccuracy=FALSE;
for(i=0;i<25;i++)
{
printf("%d\n",i);
pm=imaqFindPattern(SrcImg,RefImg,IMAQ_NO_ROTATED_RECT,&o,NULL,&n);
Sleep(1000);
if(pm) imaqDispose(pm);
}
return 0;
}
07-06-2009 09:17 AM - edited 07-06-2009 09:17 AM
Has there been any progress on this discussion? I am also experiencing memory issues that my be related to the FindPattern function. I believe I would find the results of this discussion very helpful.
Thanks,
Manson
11-03-2009 02:54 AM - edited 11-03-2009 02:56 AM
It is still an issue for me!
I have attached two TaskManager images of my program. In the first image my program runs with two source code lines turned OFF:
pm=imaqFindPattern(input_image,ref_image,RectROI,&PhotoFindPatternOptions,NULL,&n);
if(pm!=NULL) {imaqDispose(pm); pm=NULL;}
And in the second image my program runs with these two source code lines turned ON.
I know this does not make much sense running the program with these lines turned ON, but it is a way to be sure that the memory leak is in these two lines.
The result is obious: there is a memory leak in this function!
11-03-2009 01:39 PM
Good news! After installing the NI-Vision update 8.6.1 the memory leak disappeared!
So, if you have memory issues with imaqFindPattern, locate, install and download the 27Mb NI update.
11-03-2009 03:19 PM