Zig course

Zig Level 3: Allocators

Allocators is level 3 of 11 of the LoWisa Zig course. It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

Updated 2026-11-25

Explicit Allocation

  • The allocator parameter. Anything allocating takes an allocator argument: heap use visible in every signature.
  • alloc and free. Memory returns through alloc and leaves through free: with defer pairing them on the same screen.
  • No global allocator. Zig ships no blessed global allocator: the choice is yours, per program, per subsystem.

Allocator Interfaces

  • The Allocator interface. Allocator is a standard interface: code written against it runs on any strategy.
  • GeneralPurposeAllocator. The general-purpose allocator detects leaks and use-after-free in debug: a sanitizer built in.
  • Arenas and fixed buffers. Arena allocators free everything at once; fixed buffers allocate from a stack array: strategies as values.

Designing Memory Ownership

  • Ownership documented. APIs document who frees: the caller, the callee, or the arena that outlives both.
  • Arena per task. Request-scoped work uses an arena: allocate freely, free once, leaks impossible by shape.
  • Testing allocators. Tests run under the testing allocator: leaks and double-frees failing the suite loudly.

Before and after this level

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.

Frequently asked questions

What does Zig Level 3: Allocators cover?

Explicit Allocation, Allocator Interfaces, Designing Memory Ownership: 3 lessons and 9 ideas.

What should I know before this level?

The level before it, Level 2: Pointers & Memory, which covers Pointers, Slices, Memory Representation.

Learn Zig on your phone

The first level is free. LoWisa is on Google Play and the App Store.