https://github.com/shoenig/offheap
offheap - allocate system memory off heap in Go
https://github.com/shoenig/offheap
collection garbage gc go golang hacktoberfest heap memory offheap
Last synced: about 1 year ago
JSON representation
offheap - allocate system memory off heap in Go
- Host: GitHub
- URL: https://github.com/shoenig/offheap
- Owner: shoenig
- License: bsd-3-clause
- Created: 2015-02-25T05:37:35.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2024-11-01T18:45:39.000Z (over 1 year ago)
- Last Synced: 2025-03-19T02:38:21.863Z (over 1 year ago)
- Topics: collection, garbage, gc, go, golang, hacktoberfest, heap, memory, offheap
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
offheap
=======
Allocate offheap memory in Go programs

# Project Overview
Package `offheap` provides a simple library for allocating offheap memory in
Go programs. Doing so is useful for allocating large `[]byte` that should not
be managed by the garbage collector.
# Getting Started
The `offheap` package can be installed by running
```bash
go get github.com/shoenig/offheap
```
#### Example Usage
```go
package main
import (
"fmt"
"github/shoenig/offheap"
)
func main() {
var m offheap.Memory
var e error
// allocate 5 MB
if m, e = offheap.New(5 * 1024 * 1024); e != nil {
panic(e)
}
fmt.Println("m[0]", m[0])
m[0] = 42
fmt.Println("m[0]", m[0])
if e = m.Unmap(); e != nil {
panic(e)
}
fmt.Println("finished")
}
```
# Contributing
Package `offheap` is pretty minimalist, and so it's basically feature complete.
Bug fixes and good ideas though are always welcome, please just file an issue.
# License
The `github.com/shoenig/offheap` module is open source under the [BSD-3-Clause](LICENSE) license.