1min.

1MIN · GO

Go can grow small slices on the stack before using the heap

Go’s compiler can use a small stack buffer for certain slice allocations before falling back to the heap. The official explanation traces improvements in Go 1.25 and 1.26, including slices built with append and some returned slices. Avoiding intermediate heap allocations reduces allocator work and garbage that would otherwise need collecting.

Go Project · Feb 27, 2026

Why it matters

Useful when profiling allocation-heavy Go code or deciding whether manual slice preallocation is worthwhile.

More context

This February article is older technical reading, separate from recent allocator specialization. Compare allocation counts with representative benchmarks on your supported toolchain before introducing manual buffers or capacity guesses.

Keep in mind

The optimization depends on compiler analysis, slice size and escape behavior. It does not promise zero allocations for every slice; 1min has not measured your workload.

Original read

More engineering ideas, one minute at a time.

Explore more stories