Go 1.25 and 1.26 introduce compiler optimizations that move slice allocations from the heap to the stack, reducing garbage collector pressure and improving performance. In Go 1.25, variable-sized make calls with small enough sizes are automatically backed by a 32-byte stack buffer. In Go 1.26, append-allocated slices also get a
•10m read time• From go.dev
Table of contents
Stack allocation of constant-sized slices ¶Stack allocation of variable-sized slices ¶Stack allocation of append-allocated slices ¶Stack allocation of append-allocated escaping slices ¶Wrapping up ¶Footnotes ¶Sort: