Previously, we allocated a massive amount of transient (single-frame-only) command stream memory and just chipped into that with a linear allocator. This broke if we needed more than we allocated, and it used an absurd amount of memory when we didn't.
We continue to use a linear allocator for transient data, but we allocate only a small slab on start-up. As more memory is needed, we gradually increase the size of the pool, ensuring small apps require minimal memory and large apps have enough for their needs.
This patch, in combination with the pb memory management patch on which this patch depends, results in es2gears using one-tenth of the memory. That's a 90% savings!
The other patch must be merged first.