---
name: "std::pmr_monotonic_buffer_resource"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::pmr_monotonic_buffer_resource"
---

# std::pmr\_monotonic\_buffer\_resource(3)

A memory resource that allocates from a fixed-size buffer.

## NAME

std::pmr::monotonic\_buffer\_resource - A memory resource that allocates from a fixed-size buffer.

## SYNOPSIS

\#include \<memory\_resource\>

Inherits **std::pmr::memory\_resource**.

### Public Member Functions

**monotonic\_buffer\_resource** (const monotonic\_buffer\_resource &)=delete\
 **monotonic\_buffer\_resource** (memory\_resource \*\_\_upstream) noexcept\
 **monotonic\_buffer\_resource** (size\_t \_\_initial\_size) noexcept\
 **monotonic\_buffer\_resource** (size\_t \_\_initial\_size, memory\_resource \*\_\_upstream) noexcept\
 **monotonic\_buffer\_resource** (void \*\_\_buffer, size\_t \_\_buffer\_size) noexcept\
 **monotonic\_buffer\_resource** (void \*\_\_buffer, size\_t \_\_buffer\_size, memory\_resource \*\_\_upstream) noexcept\
 void \* **allocate** (size\_t \_\_bytes, size\_t \_\_alignment=\_S\_max\_align)\
 void **deallocate** (void \*\_\_p, size\_t \_\_bytes, size\_t \_\_alignment=\_S\_max\_align)\
 bool **is\_equal** (const memory\_resource &\_\_other) const noexcept\
 monotonic\_buffer\_resource & **operator=** (const monotonic\_buffer\_resource &)=delete\
 void **release** () noexcept\
 memory\_resource \* **upstream\_resource** () const noexcept\

### Protected Member Functions

void \* **do\_allocate** (size\_t \_\_bytes, size\_t \_\_alignment) override\
 void **do\_deallocate** (void \*, size\_t, size\_t) override\
 bool **do\_is\_equal** (const memory\_resource &\_\_other) const noexcept override\

## Detailed Description

A memory resource that allocates from a fixed-size buffer.

The main feature of a pmr::monotonic\_buffer\_resource is that its do\_deallocate does nothing. This makes it very fast because there is no need to manage a free list, and every allocation simply returns a new block of memory, rather than searching for a suitably-sized free block. Because deallocating is a no-op, the amount of memory used by the resource only grows until release() (or the destructor) is called to return all memory to upstream.

A monotonic\_buffer\_resource can be initialized with a buffer that will be used to satisfy all allocation requests, until the buffer is full. After that a new buffer will be allocated from the upstream resource. By using a stack buffer and pmr::null\_memory\_resource() as the upstream you can get a memory resource that only uses the stack and never dynamically allocates.

**Since**

C++17

## Member Function Documentation

### void \* std::pmr::monotonic\_buffer\_resource::do\_allocate (size\_t \_\_bytes, size\_t \_\_alignment) \[inline\], \[override\], \[protected\], \[virtual\]

Implements **std::pmr::memory\_resource**.

### void std::pmr::monotonic\_buffer\_resource::do\_deallocate (void \* , size\_t , size\_t ) \[inline\], \[override\], \[protected\], \[virtual\]

Implements **std::pmr::memory\_resource**.

### bool std::pmr::monotonic\_buffer\_resource::do\_is\_equal (const memory\_resource & \_\_other) const \[inline\], \[override\], \[protected\], \[virtual\], \[noexcept\]

Implements **std::pmr::memory\_resource**.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
