TRT
Sign in

Expert · Module 13 · Lesson 2 of 6

A Pool Allocator for Fixed-Size Nodes

Build a fixed-size pool with a free list, allocate and deallocate in constant time, and test it against new for one node type.

Pro — members onlyAbout 10 minutes

By the end you can

  • Build a fixed-size pool that reuses blocks through a free list
  • Implement allocate and deallocate with reused memory and clear ownership
  • Compare pool timing against new with the honest harness

Builds on Why Allocation Dominates: Measuring new and vector.

01 · A question first

The prior lesson blamed seventy percent of parser time on one million news of the same node size. The general heap still searches and locks for blocks you already know the size of. How do you trade that generality for a stack of ready blocks cut to one size?

Make a guess before you read on.

02 · The idea

Members only

Unlock the full lesson

This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.

What's inside

  • Start with the problem
  • How the idea works
  • A tray of equal cups
  • Why it is correct
  • What it costs
  • Pitfalls and variations
  • Where it is used

03 · Practice

Something wrong with this lesson? Report a problem