Use the arena package to allocate memory in bulk and free it manually, bypassing the garbage collector for short-lived, high-volume allocations. This reduces GC pauses and total memory churn by returning memory to the runtime immediately after use.
import "arena"
func process() {
a := arena.NewArena()
defer a.Free()
// Allocate many objects in the arena
items := arena.MakeSlice[int](a, 0, 10000)
// ... use items ...
// Memory is freed instantly when a.Free() runs
}