libvmem

The libvmem library

libvmem supports the traditional malloc/free interfaces on a memory mapped file. This allows the use of persistent memory as volatile memory, for cases where the pool of persistent memory is useful to an application, but when the application doesn’t need it to be persistent.

Note: Since persistent memory support has been integrated into libmemkind, that library is the recommended choice for any new volatile usages, since it combines support for multiple types of volatile memory into a single, convenient API.

Man pages that contains a list of the Linux interfaces provided:

Man pages that contains a list of the Windows interfaces provided:

libvmem Examples

More Detail Coming Soon

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libvmem.h>

int
main(int argc, char *argv[])
{
	VMEM *vmp;
	char *ptr;

	/* create minimum size pool of memory */
	if ((vmp = vmem_create("/pmem-fs",
					VMEM_MIN_POOL)) == NULL) {
		perror("vmem_create");
		exit(1);
	}

	if ((ptr = vmem_malloc(vmp, 100)) == NULL) {
		perror("vmem_malloc");
		exit(1);
	}

	strcpy(ptr, "hello, world");

	/* give the memory back */
	vmem_free(vmp, ptr);

	/* ... */
}

The contents of this web site and the associated GitHub repositories are BSD-licensed open source.