The main thing with fragmentation is to avoid constantly freeing and re-allocating the same objects. In your case, if you're calling draw_image frequently, then it might be a good idea to make the buffer permanent (i.e. allocate once on startup).
The main thing with fragmentation is to avoid constantly freeing and re-allocating the same objects. In your case, if you're calling draw_image frequently, then it might be a good idea to make the buffer permanent (i.e. allocate once on startup).