I have been noticing that my programs' memory usage keeps increasing pointlessly at times. Specially when i am using cvWaitKey(0), my program tends to shoot memory usage in 10 seconds to a huge size. 
Is there a fix for this, or this is an OpenCv bug?
I have a simple function called Show_Image, to we which have set a callback function to get the pixel values:
void Show_Image(IplImage *img)
{
    cvNamedWindow("IMAGE_WINDOW", CV_WINDOW_AUTOSIZE); 
    cvSetMouseCallback("IMAGE_WINDOW", GETPIXEL , (void*)img);
    cvShowImage("IMAGE_WINDOW", img );
    cvWaitKey(0);
    cvDestroyWindow("IMAGE_WINDOW");
}
 
     
    