Crashing in ofPixels::allocate


My app (OF 0.8.4) is crashing once in a while, in ofPixels::allocate using ofxVideoRecoder. It is trying to allocate too much memory (even though I’m not running out of memory). All the info shown by the debugger seems to correct though (width, height, nb of channels). Here is a screenshot, is there anything helpful I’m missing on that screen.


Of course I was doing something wrong :slight_smile:

Well I did not solve this crash after all. Back to square one.

Looking at the code, I can see that ‘new PixelType[]’ is called using both the arguments passed to the ‘allocate()’ method (w and h), instead of the variables ‘width’ and ‘height’.

channels = _channels;
width= w;
height = h;

pixels = new PixelType[w * h * channels];

And if you look at the debugger the arguments ‘h’ and ‘_channels’ seems empty (at least the debugger shows nothing more than their types), even though the variables ‘height’ and ‘channels’ have values (which are correct).

Could it be the error leading to the crash (trying to allocate to much ram)?

Any advices are appreciated.


Ok… let’s put an end to this monologue :wink:

The app was crashing because it was trying to allocate too much heap memory. The issue was of course not in ofPixels::allocate(), but in a ‘while’ loop in a threaded function of ofxVideoRecorder. Here is the link to a PR if anyone is interested: PR #23


I’m having a similar issue. It seems ofPixels::allocate crashes only on debug mode.
If i comment out the clear() in ofPixels::allocate() the crash does not happen anymore.

any ideas what could this be? why only crashes on debug?