[Cogl] [Robert Bragg] Re: [PATCH 3/3] Allow propogation of OOM errors to apps

Neil Roberts neil.s.roberts at intel.com
Tue Nov 20 05:59:54 PST 2012


Robert Bragg wrote:

> Yeah I considered this but I'm not sure about this. Running out of
> memory due to allocating large images isn't an entirely uncommon
> problem so my current feeling is that for large image based resource
> allocations the Cogl api should put some emphasis on error handling to
> encourage developers to try handling oom errors gracefully if
> possible.
>
> The trade-off here seems to be that it makes the api a bit asymmetric
> but I'm not sure that's too bad? I suppose possibly we could add a
> cogl_pixel_buffer_new_with_size() to be consistent and then simply
> drop cogl_pixel_buffer_new() but then that's maybe a bit inconvenient?

Ok, I agree that there is a difference with allocating resources for
images (and thus pixel buffers) so I think it'd be fine to make the API
different.

I think we should add cogl_pixel_buffer_new_with_size though and make it
not take an error. The buffer isn't allocated until data is set on it so
there can't be an error. With cogl_pixel_buffer_new it's not obvious
that passing NULL for the data parameter means that it can not throw an
error.

Passing data on construction probably isn't that useful for pixel
buffers. The only real use for pixel buffers is an interim buffer to
create a texture. If you already have the data ready in CPU-side memory,
you might as well just use cogl_texture_new_from_data and let the driver
make a temporary copy if it would make sense.

We can worry about adding cogl_buffer_buffer_new_with_size in a later
patch though and keep the changes you've made as is for now.

Regards,
- Neil
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



More information about the Cogl mailing list