Namespaces
Variants

std::pmr::monotonic_buffer_resource:: release

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
void release ( ) ;
(自 C++17 起)

通过在上游内存资源上调用 deallocate 函数来释放所有已分配的内存。将 当前缓冲区 下一个缓冲区大小 重置为构造时的初始值。

即使某些已分配内存块的 deallocate 未被调用,内存仍会被释放回上游资源。

缺陷报告

下列行为变更缺陷报告被追溯应用于先前发布的C++标准。

缺陷报告 应用于 发布时行为 正确行为
LWG 3120 C++17 release 在提供缓冲区时可能无法使其可重复使用 要求必须实现此功能

参见

释放内存
( std::pmr::memory_resource 的公开成员函数)