Go 1.27.4 GOMEMLIMIT increases physical memory use for untouched slices

peng.fyi7 min read

Under GOMEMLIMIT, Go programs that allocate large untouched slices can experience a significant increase in physical memory usage due to the runtime marking spans as needing zeroing. When an allocation starts slightly below a high-water mark, the Go runtime clears the entire large block with a write, causing the kernel to back every page with physical memory. Allocating buffers outside the Go heap via mmap avoids this runtime behavior. Open article →