Can ofPixels' memcpy potentially cause memory issues?

I’m updating a lot of ofPixels instances with new data at every frame.

I’m using the ofPixels::setFromAligned method. Deep within its implementation a memcpy is performed to store the image data inside the ofPixels instance.

Sometimes, with bigger images I get memory problems, ofThread bad allocation arises. I’m wondering whether it would be because using memcpy instead of memmove, which makes sure you’re not overlapping source and destination.

as long as you are not trying to copy and ofPixels into itself or something weird like that it should be fine. memove is slower than memcpy, that’s why we use memcpy. if you are having crashes on threads + memory usage it’s most probably from wrong locking between threads

1 Like