PMEMALLOCATOR(3)
π NAME π
libmemkind::pmem::allocator<T> β the C++ allocator bestie that plays nice with the C++ standard library allocator concepts π
Heads up, queen: the pmem_allocator.h functionality is considered stable API (STANDARD API). So like, it's not gonna ghost you. π«Ά
β¨ SYNOPSIS β¨
#include <pmem_allocator.h>
Link with -lmemkind
libmemkind::pmem::allocator(const char *dir, size_t max_size);
libmemkind::pmem::allocator(const char &dir, size_t max_size, libmemkind::allocation_policy alloc_policy);
libmemkind::pmem::allocator(const std::string &dir, size_t max_size);
libmemkind::pmem::allocator(const std::string &dir, size_t max_size, libmemkind::allocation_policy alloc_policy);
template <typename U> libmemkind::pmem::allocator<T>::allocator(const libmemkind::pmem::allocator<U>&) noexcept;
template <typename U> libmemkind::pmem::allocator(const allocator<U>&& other) noexcept;
libmemkind::pmem::allocator<T>::~allocator();
T *libmemkind::pmem::allocator<T>::allocate(std::size_t n) const;
void libmemkind::pmem::allocator<T>::deallocate(T *p, std::size_t n) const;
template <class U, class... Args> void libmemkind::pmem::allocator<T>::construct(U *p, Args... args) const;
void libmemkind::pmem::allocator<T>::destroy(T *p) const;
πΈ DESCRIPTION πΈ
So basically, libmemkind::pmem::allocator<T> is the allocator you pull up when you wanna use it with STL containers to allocate persistent memory. The way it does memory management? It's built on memkind_pmem (that's the memkind library, babe). If you want the full lore, go read memkind_pmem(3) and memkind(3). β¨
libmemkind::allocation_policy is the thing that tells the allocator how it should use memory β it's literally the vibe-setter for memory utilization tuning. Here are the available types of allocator usage policy:
libmemkind::allocation_policy::DEFAULTβ the default allocator memory usage policy. The main character, the standard. πlibmemkind::allocation_policy::CONSERVATIVEβ the conservative allocator memory usage policy. This one prioritizes memory usage at the cost of performance. She's careful, she's mindful, she's not here for speed. π§
All public member types and functions correspond to standard library allocator concepts and definitions, no cap. The current implementation supports the C++11 standard.
Template arguments:
Tβ an object type aliased byvalue_type.Uβ an object type.
Note, bestie, read this part:T *libmemkind::pmem::allocator<T>::allocate(std::size_t n)allocates persistent memory usingmemkind_malloc(). It throwsstd::bad_allocwhen: -n = 0- or there is not enough memory to satisfy the request. π
libmemkind::pmem::allocator<T>::deallocate(T *p, std::size_t n) deallocates the memory associated with the pointer that was returned by allocate(), and it does it using memkind_free(). Cleanup era. π
π COPYRIGHT π
Copyright (C) 2018 - 2021 Intel Corporation. All rights reserved.
π SEE ALSO π
Okay that's the whole page, babe β this was the PMEMALLOCATOR(3) manual, brought to you by Intel Corporation, dated 2018-09-13, and yes, the page itself is literally called PMEMALLOCATOR(3). Slay, go allocate something iconic. πβ¨
π¦ where this page comes from
- debian bookworm: libmemkind-dev 1.14.0-2 Β· BSD-3-Clause
- fedora 43: memkind-devel 1.14.0-11.fc43 Β· BSD-2-Clause
- ubuntu jammy: libmemkind-dev 1.13.0-1 Β· BSD-3-Clause
- ubuntu noble: libmemkind-dev 1.14.0-3build1 Β· BSD-3-Clause
- π the page's license: BSD-2-Clause
- Copyright (C) 2018 - 2021 Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms