PMEMALLOCATOR(3)

πŸ“¦
version 1.14.0 Β· 2 versions
, in debian bookworm, fedora 43, ubuntu jammy, ubuntu noble

πŸ’– 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 by value_type.
  • U β€” an object type.
Note, bestie, read this part: T *libmemkind::pmem::allocator<T>::allocate(std::size_t n) allocates persistent memory using memkind_malloc(). It throws std::bad_alloc when: - 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 (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