Chapter 15Memory Management MechanicsPaid chapter

The Allocator — Size Classes, the Tiny Allocator, and Scan vs Noscan

Understand how mallocgc places objects: size-class rounding, the tiny allocator, and why pointer-free allocations are cheaper for the GC — connecting allocation (Part I) to GC cost (Chapter 16).

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

Allocating N bytes uses N bytes, and all allocations cost the GC the same.

What actually happens

mallocgc rounds every request up to a fixed size class, batches tiny pointer-free objects, and marks pointer-free (noscan) memory far more cheaply than pointer-containing memory.

Mechanisms covered
The tiny allocator packs multiple small (<16 B) pointer-free allocations into one block, reducing both allocation count and overhead.
Spans are marked scan or noscan. The GC must scan pointer-containing objects for references; pointer-free objects (e.g., []byte, []int) are noscan and skipped during marking — so they impose far less GC mark cost.
experimentbenchtrace
Email-first checkoutUnlock Chapter 15

Unlock Chapter 15 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.

Choose a plan

You'll head to Lemon Squeezy for secure checkout. Global tax is handled there. No subscription. Complete also includes the practical exam and free Go-version updates.

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.