Skip to content

Document premature allocator destruction requirement for memory resources #39

@kammce

Description

@kammce

std::pmr::memory_resource* allocator = nullptr;

Why?

The lifetime of the memory resource is not bound to the ref_info that made it, meaning that the memory resource can be destroyed early and cause lifetime issues. A solution around this is to force the memory resources to be managed by strong_ptr.

But how do you get a strong_ptr from an object that needs a strong_ptr for its control block. And the answer is static memory or global allocators. The static strong_ptr's do not need control blocks since they live for the duration of the program and thus can be the backbone of every other strong_ptr. This will ensure memory safety for our smart pointers.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions