Memory Arena Library is a Golang package that consolidates multiple related memory allocations into a single area. This design allows you to free all allocations at once, making memory management simpler and more efficient.
- Grouped Memory Allocations: Manage related objects within a single arena, streamlining your memory organization.
- Efficient Cleanup: Release all allocations in one swift operation, simplifying resource management.
- Concurrency Support: Use with concurrent operations via a dedicated concurrent arena.
Install the latest version with:
go get github.com/Raezil/memoryArena@latest
Usage Example
Below is an example demonstrating how to create a memory arena, allocate objects, and free them efficiently:
package main
import (
"fmt"
. "github.com/Raezil/memoryArena"
)
type Person struct {
Name string
Age int
}
func main() {
arena, err := NewConcurrentArena[[]Person](100)
if err != nil {
return
}
obj, _ := NewObject[[]Person](arena, []Person{Person{"Kamil", 27}, Person{"Lukasz", 28}})
defer Reset(arena)
fmt.Println(obj)
}
Testing
To run the tests, execute:
go test
Want to improve memoryArena? 🚀
- Fork the repo
- Create a feature branch (
git checkout -b feature-new
) - Commit your changes (
git commit -m "Added feature"
) - Push to your branch (
git push origin feature-new
) - Submit a PR!