Memory leak in ofPixels::copyFrom

The ofVideoPlayer seems to be leaking memory under 64bit Linux (Ubuntu 10.10). I’m using the newest versions from git (updated today). I think that the same bug has been there for at least about one month, if I remember correctly…

The problem does NOT exists with pre release v0.062.

I’m having this problem with both my own app as well as with moviePlayerExample. (with the example, make this bug more visible by changing fingers.mov with some larger/longer movie)

Has anyone else observed the same bug? Any hints what might be the reason?

Yep, the bug and solution found! :slight_smile:
I traced the problem and it seems that the memory leak actually happens in ofPixels::copyFrom method:

  
void ofPixels::copyFrom(const ofPixels & mom){  
	bAllocated = false;  
	pixels = NULL;  
	if(mom.isAllocated()){  
		allocate(mom.getWidth(),mom.getHeight(),mom.getImageType());  
		memcpy(pixels,mom.getPixels(),mom.getWidth()*mom.getHeight()*mom.getBytesPerPixel());  
	}  
}  

And more precisely on the line “pixels = NULL”. My suggestion as a solution is to remove the first two lines of this method. I don’t understand their meaning, since the (re)allocation seems to be correctly handled by the allocate method…

This solution worked for me. Could someone (with git-repository access) check this correction and take it into account?

Cheers, Juuso

PS. The subject of this post was updated to be more precise.

thanks! should be fixed now

You’re welcome! :wink: