# **[](https://en.cppreference.com/w/cpp/header/memory_resource)** provides polymorphic memory allocators: `std::pmr::memory_resource` and standard containers adapted to use them, like `std::pmr::vector`, `std::pmr::string`. This allows switching allocators (stack, arena, monotonic) at runtime without changing container types. Use it when you need custom allocation strategies; most code just uses the default allocator. ## Example This example uses a pmr vector with the default new_delete resource, demonstrating polymorphic memory allocation. ```cpp // compile: g++ -std=c++17 -o memoryresourceexample memoryresourceexample.cpp // run: ./memoryresourceexample // description: pmr vector with a memory resource #include #include #include int main() { std::vector> vec(std::pmr::new_delete_resource()); vec.push_back(1); vec.push_back(2); std::cout << "vec size: " << vec.size() << "\n"; return 0; } ```