Expand description

Binary-buddy allocation.

The buddy algorithm divides the managed region into a fixed number of equal, power-of-two-sized blocks. Each block can be recursively split in half a fixed number of times in order to provide finer-grained allocations. Buddy allocators excel in cases where most allocations have a power-of-two size.

Characteristics

Time complexity
OperationBest-caseWorst-case
Allocate (size <= align)O(1)O(log2levels)
DeallocateO(1)O(log2levels)
Fragmentation

Buddy allocators exhibit limited external fragmentation, but suffer up to 50% internal fragmentation because all allocatable blocks have a power-of-two size.

Structs

A binary-buddy allocator.

The raw parts of a Buddy.