0PricingLogin
Zig Academy · Lesson

GeneralPurposeAllocator for Debug Safety

Catch leaks and double-frees.

Your Default Choice

When you are not sure which allocator to use, reach for the GeneralPurposeAllocator. It is safe, flexible, and great while you develop. 🛡️

Create One

The GeneralPurposeAllocator is a generic type you instantiate. You create an instance and then ask it for the actual allocator interface.

var gpa = std.heap.GeneralPurposeAllocator(.{}){};

All lessons in this course

  1. GeneralPurposeAllocator for Debug Safety
  2. Arena Allocators for Bulk Free
  3. FixedBufferAllocator with No Heap
  4. Choosing an Allocator per Workload
← Back to Zig Academy