Chapter 15Memory Management MechanicsPaid chapter

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

Distinguish tiny packing and size classes and measure scan work separately from collection timing.

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 and Complete. 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 every allocation costs the garbage collector the same amount to manage.

What actually happens

the small-object allocator rounds eligible requests to a size class: a 17-byte pointer-free allocation uses a 24-byte slot in this edition. Tiny allocations and large objects take different paths. Tiny (< 16-byte) pointer-free objects are packed several to a block by the tiny allocator. And — most importantly — an object the GC can see contains no pointers is marked noscan and never scanned during collection, while a pointer-containing object is scanned, its cost proportional to its pointers. So two same-size objects can cost the GC very differently, and a pointer-free representation can be dramatically cheaper to collect.

Mechanisms covered
Pointer-free backing arrays avoid scanning their elements; they still participate in reachability and reclamation.
Runtime scan metrics and whole-collection wall time answer different questions; timing is not a pause-duration measurement.
experiment
One-time purchase

Unlock Chapter 15 and the rest of the course.

Core unlocks every paid chapter and lab. Complete also includes the practical exam and future Go-version updates.

Core
$49

Full course access with the complete mechanics curriculum.

All paid chapters unlocked
One-time purchase
Perfect if you want the material only
Complete
$79
Best value

Best-value launch option with the exam and free Go-version course updates.

Everything in Core
Black Belt practical exam
Free Go-version updates

No subscription or account required. Access is tied to the email entered at Stripe Checkout and can be restored by email.

Free chapter
Escape Analysis: The Compiler's Fragile Decision
Distinguish escape diagnostics from measured allocations and explain the role of lifetime and call-site visibility.
Free chapter
Maps: Swiss Tables, Growth, and Permanent Memory
Distinguish map table capacity from referenced payloads and inspect clearing and growth on Go 1.25.