Home

Awesome

Erlang MMAP emmap

This Erlang library provides a wrapper that allows you to memory map files into the Erlang memory space.

Basic Usage

The basic usage is

{ok, Mem} = emmap:open("filename", [read, shared, direct]),
{ok, Binary} = file:pread(Mem, 100, 40),
...
ok = file:close(Mem).

The open options is a list containing zero or more of these:

From this point, Mem can be used with the file operations

Notes

Using the option direct has the effect that the mmap file is not closed until all references to binaries coming out of read/pread have been garbage collected. This is a consequence of that such binaries are referring directly to the mmap'ed memory.