Skip to content
JavaScript bindings for libpmemobj
C++ Shell JavaScript Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

libpmemobj-js: Persistent Memory Development Kit for JavaScript*

The Persistent Memory Development Kit for JavaScript* (libpmemobj-js) is a project to provide a Node.js module to store JavaScript objects in persistent memory. One of the goal of the project is to make programming with persistent JavaScript objects feels natural to developer. We have implemented persistent JavaScript classes including PersistentObject, PersistentArray and PersistentArrayBuffer, however they are not fully performance-optimized. Please see our examples and API document for details.

This module uses the libpmemobj library from the Persistent Memory Development Kit (PMDK). For more information on PMDK, please visit and


  • Node.js 8.x or higher
  • PMDK - native persistent memory libraries
  • node-addon-api - header-only C++ wrapper classes which simplify the use of the C based N-API provided by Node.js
  • bindings - Helper module for loading native module's .node file
  • Use only for testing


Get the Codes

$ git clone
$ cd libpmemobj-js

Build libpmemobj-js

You can build the dependency to PMDK by using our script, then install libpmemobj-js by npm

$ cd deps
$ ./
$ cd ../src
$ npm install


After build, you can run the tests by

$ LD_LIBRARY_PATH=/usr/local/lib mocha ../tests


We are using memory to emulate a persistent memory.

const jspmdk = require('jspmdk');
const constants = jspmdk.constants;

// you should specify your own path to persistent memory here
var path = '/path/to/pmem/file';
var pool = jspmdk.new_pool(path, constants.MIN_POOL_SIZE);

var check = pool.check();
if (check == -1) {
  // not exists
else if (check == 0) {
  // not consistent
else if (check == 1) {
  // exists and consistent;

var root = pool.root;
pool.root = undefined;

// persistent Object
var pobj = pool.create_object({a: 1});
var a = pobj.a;
pobj.b = 2;
delete pobj.b;

// persistent Array
var parr = pool.create_object([1, 2]);
if (parr.is_array()) {

// persistent ArrayBuffer
var pab = pool.create_arraybuffer(new ArrayBuffer(10));
var pab_uint8 = new Uint8Array(pab);
pab_uint8[0] = 1;
pab.persist(0, 1)

// close object pool
You can’t perform that action at this time.