dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: possible fix for skin buffer issues

possible fix for skin buffer issues

From: Jonathan Gordon <>
Date: Sun, 9 Oct 2011 23:37:30 +1100

Braindump for someone to pick up to fix the skin buffer memory
allocation "issue".

The "problem" is that The vast majority of the skin buffers static
allocation goes to the struct skin_element which is allocted for every
single item in the skin file. Every line, tag, subline, comment, etc.
on e200 this comes out to 41KB (going from memory). The next biggest
allocation is struct skin_token, which is 20x smaller in total than

So obviously there is no point doing anything except move skin_element
onto buflib.
This is *problematic* because they are used, well everywhere.

My braindump fix is this:
1) give the lib a callback which will allocated 1000 skin_element
structs in a block (we obviously dont want 600 allocations for this)
2) in skin_alloc_element() allocate from the above array instead of
the skin_buffer (when it is full allocate another 1000 or so)
3) in skin_render_viewport() (and a few other places) lock all those handles
4) in the move callback, walk the entire skin tree (this means every
tree loaded) and update each pointer. This is going to be slow and
crap, but hopefully not done often.

I *think* those items are only used when traversing the tree so it is
possible the pointer updating could even be done delayed (so store the
diff somewhere and update the first time it is traversed after the
move - Though this could be very dangerous, actually yeah, dont do
this. hidden viewports are ignored at render time).

I'm not sure what the alternatives are, this is a pretty nasty
solution. Hopefully someone comes up with a better one (or implements
this as I don't particularly have interest in doing it right now, but
thought it would be good to explain the issue and a solution.)

Received on 2011-10-09

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy