In a similar vein to http://graphics.stanford.edu/~seander/bithacks.html, I'm curious to hear the people's choice for memory pool/slab allocators. My question is a three-parter:
1) Allocation size function: Do you allocate fixed size chunks of N objects at a time? Exponential increase in chunk size (I believe valgrind does this for its memchecker)? If exponential, do you also back off exponentially, or linearly? Something else?
2) Used/free record keeping: Bitfield? Linked-list? Other?
3) New allocations: realloc or array/linked list of pointers (I bet I know the answer to this one)?
Some justification would be nice, if you've got the time.
I use arena allocators when I can get away with it. Arenas are absolutely trivial to code; there's no per-object "free", so allocation is just a pointer bump. You will be surprised at how often you can get away with this; lots of allocation-heavy code paths map to a single operation, transaction, request, file, or what-have-you, and all you're doing is deferring free to the end of it. Using arenas in this scenario basically erases the cost of allocation from your program. It's also dramatically harder to fuck up.
For anything else, when malloc hits the top of my profile, I have a simple freelist library for pools of homogenous allocations, with an embedded linked list of free items.
You could get smarter than an arena, a generic freelist, and malloc, but why?