There are a few ways to solve that problem, but I would start with the
simplest possible one: ignore the size altogether.. just pick an item
out of the pool, grow it as needed, and put it back when done. This
will organically grow the backing arrays as necessary. From there, if
really necessary, I'd attempt allocating power-of-two-sized slices,
and finally using separate pools with known power-of-two-sized slices
each.
Of course, it's important to carefully measure. It's way too easy to
improperly assume the impact.
--
gustavo @
http://niemeyer.net