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

  //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
Re: c++ memory problem 80 80

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
  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

(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.

Re: c++ memory problem 80 80

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.