This package simplifies dealing with memory-mapped files by wrapping related system calls and constants and providing them here in one place. Currently this package provides rather complete support for Linux and OS X Darwin. Patches for other GOOS such as BSD and Windows are welcomed as long as you keep the API reasonably consistent.
Supported system calls include:
madvise
mincore
mlock
mmap
mprotect
msync
munlock
munmap
mlockall
(Linux-only)munlockall
(Linux-only)
For the exact semantics of each system call and constant, please refer to the
man
pages on the corresponding platforms.
API documentation is available at http://godoc.org/github.com/riobard/go-mmap
Prior to Go 1.1, int
is limited to 32-bit even on 64-bit platforms. As a
result, a memory-mapped region []byte
cannot be larger than 2GB since the
length of a slice is determined by int
. Since Go 1.1 int
becomes 64-bit on
64-bit platforms, so []byte
can be significantly larger. If you are using Go
versions prior to Go 1.1, or if you are on 32-bit platforms, keep in mind the
limitation.
There are two other packages which might be useful to you if you are not satisfied by this one: