Skip to content

scottcagno/go-mmap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-mmap

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.

Documentation

API documentation is available at http://godoc.org/github.com/riobard/go-mmap

Limitations

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.

Related

There are two other packages which might be useful to you if you are not satisfied by this one:

  • gommap (doc): this one is almost what I wanted, but lacks some flags and features on Linux and Darwin.
  • mmap-go (doc): this one lacks support for mprotect and mincore, but supports Windows.

About

Easy handling of memory-mapped files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%