PMEMALLOCATOR(3)

NAME
pmem::allocator<T> - The C++ allocator compatible with the C++ standard library allocator concepts
Note: This is EXEPRIMENTAL API. The functionality and the header file itself can be changed (including non-backward compatible changes), or remove.

SYNOPSIS
#include <pmem_allocator.h>

Link with -lmemkind

pmem::allocator(const char *dir, size_t max_size)
pmem::allocator(const std::string& dir, size_t max_size)
template <typename U> pmem::allocator<T>::allocator(const pmem::allocator<U>&) noexcept
template <typename U> pmem::allocator(const allocator<U>&& other) noexcept
pmem::allocator<T>::~allocator()
T* pmem::allocator<T>::allocate(std::size_t n) const
void pmem::allocator<T>::deallocate(T* p, std::size_t n) const
template <class U, class... Args> void pmem::allocator<T>::construct(U* p, Args... args) const
void pmem::allocator<T>::destroy(T* p) const

DESCRIPTION
The pmem::allocator<T> is intended to be used with STL containers to allocate persistent memory. Memory management is based on memkind_pmem (memkind library). Refer memkind_pmem(3) and memkind(3) man page for more details.

All public member types and functions corresponds to standard library allocator concepts and definitions. The current implementation supports C++11 standard.

Template arguments:
T is an object type aliased by value_type.
U is an object type.

Note:
T* pmem::allocator<T>::allocate(std::size_t n) allocates persistent memory memory using memkind_malloc(). Throw std::bad_alloc when:
n = 0,
    or there is not enough memory to satisfy the request.

void pmem::allocator<T>::deallocate(T* p, std::size_t n) deallocates memory associated with pointer returned by allocate() using memkind_free().

To find out more about memkind_malloc() and memkind_free() read memkind(3) man page.

NOTES
The pmem::allocator<T> behavior depends on the heap manager used by memkind. Refer memkind(3) man page for more details.

COPYRIGHT
Copyright (C) 2018 Intel Corporation. All rights reserved.

SEE ALSO
memkind_pmem(3), memkind(3)