157
The memkind library serves as a wrapper that redirects memory allocation requests
from an application to an allocator that manages the heap. At the time of publication,
only the jemalloc allocator is supported. Future versions may introduce and support
multiple allocators. Memkind provides jemalloc with different kinds of memory: A static
kind is created automatically, whereas a dynamic kind is created by an application using
memkind_create_kind().
Supported “Kinds” of Memory
The dynamic PMEM kind is best used with memory-addressable persistent storage
through a DAX-enabled file system that supports load/store operations that are
not paged via the system page cache. For the PMEM kind, the memkind library supports
the traditional malloc/free-like interfaces on a memory-mapped file. When an
application calls memkind_create_kind() with PMEM, a temporary file (tmpfile(3))
is created on a mounted DAX file system and is memory-mapped into the application’s
virtual address space. This temporary file is deleted automatically when the program
terminates, giving the perception of volatility.
Figure 10-2 shows memory mappings from two memory sources: DRAM
(MEMKIND_DEFAULT) and persistent memory (PMEM_KIND).
For allocations from DRAM, rather than using the common malloc(), the
application can call memkind_malloc() with the kind argument set to MEMKIND_DEFAULT.
MEMKIND_DEFAULT is a static kind that uses the operating system’s default page size for
allocations. Refer to the memkind documentation for large and huge page support.
Figure 10-1. An overview of the memkind components and hardware support
Chapter 10 Volatile Use of persistent MeMory
Précédent

- 181/457

Suivant