Chapter 06Data Structure InternalsPaid chapter
Slices — Growth, Aliasing, and Memory Retention
Understand slice header semantics, growth behavior, aliasing hazards, and how sub-slicing retains memory.
Launch paywall
This chapter is part of the paid launch. The preview stays visible so readers can evaluate the exact scope before buying.
Included in
Core, Complete, and Team. Complete also includes the practical exam and free Go-version updates.
Preview
What this chapter teaches
Common belief
A sub-slice is a cheap, independent view of part of an array.
What actually happens
a sub-slice shares the backing array — it retains the entire array from GC and can be silently corrupted by append through an alias.
Mechanisms covered
Sub-slicing (s[a:b]) creates an alias to the original backing array. The original cannot be collected until all aliases are unreachable — even if the alias references one byte of a megabyte array.
append to a slice with cap > len mutates the shared backing array, silently corrupting other aliases.
experimenttracebench
Email-first checkoutUnlock Chapter 06
Unlock Chapter 06 and the rest of the course.
Start with your email, then continue to Lemon Squeezy checkout. Core unlocks the paid chapters, Complete adds the exam and free Go-version updates, and Team gives you 5 seats.
Free chapter
Escape Analysis — The Compiler's Fragile Decision
Understand how the compiler decides between stack and heap allocation, why the decision is fragile, and how to verify it.
Free chapter
Maps — Swiss Tables, Growth, and Permanent Memory
Understand the Go 1.24+ Swiss Table map layout, why maps don't shrink, and how to design for memory reclamation.