Blob Blame History Raw
.\"
.\" Copyright (C) 2018 - 2019 Intel Corporation.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
.\" 1. Redistributions of source code must retain the above copyright notice(s),
.\"    this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright notice(s),
.\"    this list of conditions and the following disclaimer in the documentation
.\"    and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS
.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
.\" EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
.\" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.TH "PMEMALLOCATOR" 3 "2018-09-13" "Intel Corporation" "PMEMALLOCATOR" \" -*- nroff -*-
.SH "NAME"
libmemkind::pmem::allocator<T> \- The C++ allocator compatible with the C++ standard library allocator concepts
.br
.BR Note:
.I pmem_allocator.h
functionality is considered as stable API (STANDARD API).
.SH "SYNOPSIS"
.nf
.B #include <pmem_allocator.h>
.sp
.B Link with -lmemkind
.sp
.BI "libmemkind::pmem::allocator(const char " "*dir" ", size_t " "max_size" );
.br
.BI "libmemkind::pmem::llocator(const char " "&dir" ", size_t " "max_size" ", libmemkind::allocation_policy " "alloc_policy" );
.br
.BI "libmemkind::pmem::allocator(const std::string " "&dir" ", size_t " "max_size" );
.br
.BI "libmemkind::pmem::allocator(const std::string " "&dir" ", size_t " "max_size" ", libmemkind::allocation_policy " "alloc_policy" );
.br
.BI "template <typename U> libmemkind::pmem::allocator<T>::allocator(const libmemkind::pmem::allocator<U>&)" " "noexcept;
.br
.BI "template <typename U> libmemkind::pmem::allocator(const allocator<U>&& " "other" ) " "noexcept;
.br
.BI "libmemkind::pmem::allocator<T>::~allocator();
.br
.BI "T *libmemkind::pmem::allocator<T>::allocate(std::size_t " "n" ) " "const;
.br
.BI "void libmemkind::pmem::allocator<T>::deallocate(T " "*p" ", std::size_t " "n" ) " "const;
.br
.BI "template <class U, class... Args> void libmemkind::pmem::allocator<T>::construct(U " "*p" ", Args... " "args" ) " "const;
.br
.BI "void libmemkind::pmem::allocator<T>::destroy(T " "*p" ) " "const;
.fi
.SH "DESCRIPTION"
The
.BR libmemkind::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
.BR memkind_pmem (3)
and
.BR memkind (3)
man page for more details.
.PP
The
.BR libmemkind::allocation_policy
specifies allocator memory usage policy, which allows to tune up memory utilization. The available types of allocator usage policy:
.PP
.B libmemkind::allocation_policy::DEFAULT
Default allocator memory usage policy.
.PP
.B libmemkind::allocation_policy::CONSERVATIVE
Conservative allocator memory usage policy - prioritize memory usage at cost of performance.
.PP
All public member types and functions corresponds to standard library allocator concepts and definitions. The current implementation supports C++11 standard.
.PP
Template arguments:
.br
.I T
is an object type aliased by value_type.
.br
.I U
is an object type.
.PP
.BR Note:
.br
.BI "T *libmemkind::pmem::allocator<T>::allocate(std::size_t " "n")
allocates persistent memory using
.BR memkind_malloc ().
Throw
.I std::bad_alloc
when:
.br
.RS
.I n
= 0
.RE
.br
.RS
or there is not enough memory to satisfy the request.
.RE
.PP
.BI "libmemkind::pmem::allocator<T>::deallocate(T " "*p" ", std::size_t " "n")
deallocates memory associated with pointer returned by
.BR allocate ()
using
.BR memkind_free ().

.SH "COPYRIGHT"
Copyright (C) 2018 - 2019 Intel Corporation. All rights reserved.
.SH "SEE ALSO"
.BR memkind_pmem (3),
.BR memkind (3)