[mem.res.pool.mem]

# 20 Memory management library [[mem]](./#mem)

## 20.5 Memory resources [[mem.res]](mem.res#pool.mem)

### 20.5.5 Pool resource classes [[mem.res.pool]](mem.res.pool#mem)

#### 20.5.5.4 Members [mem.res.pool.mem]

[ð](#lib:release,synchronized_pool_resource)

`void release();
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8294)

*Effects*: Calls upstream_resource()->deallocate() as necessary
to release all allocated memory[.](#1.sentence-1)

[*Note [1](#note-1)*:

The memory is released back to upstream_resource() even if deallocate has not been called
for some of the allocated blocks[.](#1.sentence-2)

â *end note*]

[ð](#lib:upstream_resource,synchronized_pool_resource)

`memory_resource* upstream_resource() const;
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8312)

*Returns*: The value of the upstream argument
provided to the constructor of this object[.](#2.sentence-1)

[ð](#lib:options,synchronized_pool_resource)

`pool_options options() const;
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8325)

*Returns*: The options that control the pooling behavior of this resource[.](#3.sentence-1)

The values in the returned struct may differ
from those supplied to the pool resource constructor in that
values of zero will be replaced with implementation-defined
defaults, and sizes may be rounded to unspecified granularity[.](#3.sentence-2)

[ð](#lib:do_allocate,synchronized_pool_resource)

`void* do_allocate(size_t bytes, size_t alignment) override;
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8341)

*Effects*: If the pool selected for a block of size bytes is unable to satisfy the memory request from its own internal data structures,
it will call upstream_resource()->allocate() to obtain more memory[.](#4.sentence-1)

If bytes is larger than that which the largest pool can handle,
then memory will be allocated using upstream_resource()->allocate()[.](#4.sentence-2)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8349)

*Returns*: A pointer to allocated storage ([[basic.stc.dynamic.allocation]](basic.stc.dynamic.allocation "6.8.6.5.2 Allocation functions"))
with a size of at least bytes[.](#5.sentence-1)

The size and alignment of the allocated memory shall meet the requirements
for a class derived from memory_resource ([[mem.res.class]](mem.res.class "20.5.2 Class memory_­resource"))[.](#5.sentence-2)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8356)

*Throws*: Nothing unless upstream_resource()->allocate() throws[.](#6.sentence-1)

[ð](#lib:do_deallocate,synchronized_pool_resource)

`void do_deallocate(void* p, size_t bytes, size_t alignment) override;
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8368)

*Effects*: Returns the memory at p to the pool[.](#7.sentence-1)

It is unspecified if, or under what circumstances,
this operation will result in a call to upstream_resource()->deallocate()[.](#7.sentence-2)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8374)

*Throws*: Nothing[.](#8.sentence-1)

[ð](#lib:do_is_equal,synchronized_pool_resource)

`bool do_is_equal(const memory_resource& other) const noexcept override;
`

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8386)

*Returns*: this == &other[.](#9.sentence-1)
