Memory arenas
The Go 1.20 release introduced an experimental arena package that offers memory arenas. These arenas can enhance performance by decreasing the number of allocations and deallocations that need to be done during runtime.
Memory arenas are a useful tool for allocating objects from a contiguous region of memory and freeing them all at once with minimal memory management or garbage collection overhead. They are especially helpful in functions that require the allocation of many objects, processing them for a significant amount of time, and then freeing all the objects at the end. It’s important to note that memory arenas are an experimental feature, available in Go 1.20 only when the GOEXPERIMENT=arenas
environment variable is set.
Warning
The Go team does not provide support or guarantee compatibility for the API and implementation of memory arenas, and it may not exist in future releases.
Using memory arenas
Once we’ve set the GOEXPERIMENT=arenas...