IplImage *in;                                        
  CvMemStorage *storage = cvCreateMemStorage (20506);   
  CvSeq *contours=NULL;     
  CvPoint *PointArray=NULL; 


  for()
  {
  //image processing and feature extraction code here








  cvClearMemStorage (storage);         //clear memory area
      free (PointArray);
      cvReleaseImage (&in);
  }

At the end of each iteration i ma releasing memory but still i get memory shortage error after

processing 2200 images in a loop

There really is not enough to go on here. sorry.

But here is my memory error check list:

(a) Have you zeroed the pointer before trying to free it e.g.

CvPoint* PointArray=new PointArray[10];
  // stuff
  PoinitArray=0;
  delete [] PointArray;

(b) are you mixing C++ and C style memory allocations e.g. (or C and C++ delete.)

   CvPoint* PointArray=new PointArray[10];
      // stuff
      free(PointArray);

(c) Do you have loop variable that is not getting set to zero and continuously being increased and thus making your array too big to be allocated.

If all of the obvious doesn't solve the problem quickly, then tools like valgrind normally help lots.

Finally, you could post a little more code, especially the bits that allocate and deallocate memory.

IplImage *in; is uninitialized. As a result, this line cvReleaseImage (&in); could cause a core dump because the cvReleaseImage() function could read the contents of in as a valid address. Without seeing the rest of your code, I cannot say for certain.

Edited 2 Years Ago by rubberman

This article has been dead for over six months. Start a new discussion instead.