| Section | Title |
|---|---|
| 1 | Why Zig Uses Allocators |
| 2 | General Purpose Allocator |
| 3 | Arena Allocator |
| 4 | Fixed Buffer Allocator |
| 5 | Page Allocator |
| 6 | Custom Allocators |
| 7 | Allocation Failure Handling |
| 8 | Memory Leak Detection |
| 9 | Lifetime Management |
| 10 | Building Allocation-Friendly APIs |
Why Zig Uses AllocatorsMemory is one of the most important ideas in Zig.
General Purpose AllocatorThe general purpose allocator is Zig’s standard allocator for ordinary heap allocation.
Arena AllocatorAn arena allocator is an allocator that frees many allocations at once.
Fixed Buffer AllocatorA fixed buffer allocator gives memory from a buffer you already own.
Page AllocatorThe page allocator asks the operating system for memory directly.
Custom AllocatorsA custom allocator is an allocator you design for a specific memory policy.
Allocation Failure HandlingAllocation can fail.
Memory Leak DetectionA memory leak happens when a program allocates memory and then loses the ability to free it.
Lifetime ManagementMemory lifetime means:
Building Allocation-Friendly APIsAn allocation-friendly API makes memory behavior clear to the caller.