If the standard memory resources don't suit all your needs, you can always create a custom one quite simply. For instance, a good optimization that not all standard library implementations offer is to keep track of the last chunks of a given size that were released and return them back on the next allocations of given sizes. This Most Recently Used cache can help you increase the hotness of data caches, which should help your app's performance. You can think of it as a set of LIFO queues for chunks.
Sometimes you might also want to debug allocations and deallocations. In the following snippet, I have written a simple resource that can help you with this task:
class verbose_resource : public std::pmr::memory_resource { std::pmr::memory_resource *upstream_resource_; public: explicit verbose_resource(std::pmr::memory_resource *upstream_resource) : upstream_resource_(upstream_resource) {}
Our verbose resource inherits from the polymorphic...