OffsetAllocator

A fast memory offset allocator with constant-time operations and little fragmentation. It suits real-time programs such as games and graphics that need predictable allocation speed.

Share on XLicense: MIT

Overview

OffsetAllocator is a C++ allocator that hands out offsets into a range rather than memory pointers, with every operation running in constant time. It uses 256 bins sized on an 8-bit floating point scale and a two-level bitfield to find the next free bin. This bounds wasted space to at most 12.5 percent, compared with up to 100 percent for power-of-two bins. Metadata is stored separately, so it can sub-allocate GPU heaps, buffers and arrays.

Key features

  • O(1) allocation and free with hard real-time behavior
  • 256 bins on a floating point size scale
  • Waste limited to 12.5 percent, 6.25 percent on average
  • Metadata kept apart from the managed resource
  • Returns the offset of a contiguous range

Best for

Game and graphics programmers who need predictable allocation time when sub-allocating resources such as GPU buffers. It manages offsets, not the memory itself.

Upstream
sebbbi/OffsetAllocator
Fork on GitHub
Guo-astro/OffsetAllocator
Upstream stars
1.1k
Category
Developer tools and infrastructure
License
MIT
Forked
2025-10-24
Sync status
In syncLast synced 2026-09-29