A common combo of two resources is to use a pool resource on top of a monotonic buffer resource. The standard pool resources create pools of different-sized chunks. There are two types in std::pmr, unsynchronized_pool_resource for use when only one thread allocates and deallocates from it and synchronized_pool_resource for multi-threaded use. Both should provide you with much better performance compared to the global allocator, especially when using the monotonic buffer as their upstream resource. If you wonder how to chain them, here's how:
auto buffer = std::array<std::byte, 1 * 1024 * 1024>{}; auto monotonic_resource = std::pmr::monotonic_buffer_resource{buffer.data(), buffer.size()}; auto pool_options = std::pmr::pool_options{.max_blocks_per_chunk = 0, .largest_required_pool_block = 512}; auto arena = std::pmr::unsynchronized_pool_resource{pool_options, &monotonic_resource};
We create a 1 MB buffer for the arena to reuse...