Add shared pool alloc and free functions to avoid thread-specific var reads.