Move OOM checking into seperate function
Add a memory pool implementation for small allocs.

We have very many small allocations for the wordtrie nodes and the
tagged pointer arrays. The main problem is that keeping a record of the
allocations takes nearly as much space as the allocations themselves,
since the allocations are close to pointer-sized.

The memory pool implementation allocates pools of memory in a linked
list which self-extends as the pool grows. Freed memory is kept in a
vector. Note that this means that if you know you'll be freeing all of
the elements of a pool, it's better to 'leak' them and then free the
pool itself, since keeping track of the free spots will take nearly as
much memory as the pool itself.

The memory pool implementation also has a lazily-created set of default
memory pools for allocation sizes which are powers of two.
Use memory pools for tag arrays.
Use memory pools for wtrie node allocations.

This also greatly reduces the memory usage of the program -- it's down
to about 60% of what it used to be (presumably malloc won't allocate
small chunks, so there's waste).

However, the memory management for the trees is much more ugly now,
relying on several implicit global memory pools. It should be reworked.