Aligned free-block capacity is the usable payload that a particular free extent can supply after meeting memory alignment and metadata requirements. It differs from the raw extent length and from the largest free memory block. For an illustrative block , header requirement and payload alignment , the first permissible payload start is
If the allocator reserves no trailer or additional rounding, usable payload capacity is . This formula belongs to the stated layout; it is not a universal allocator ABI.
For a free interval in byte offsets, an8-byte header and16-byte alignment give . The raw64-byte extent then has51 bytes after the aligned start. Allocation alignment padding is bytes, in addition to the8-byte header. A48-byte payload fits this model, whereas a52-byte payload does not.
If allocated payload size must also be rounded to a multiple , a requested size needs usable bytes. For in the same example, the largest such payload is48 bytes: a49-byte request rounds to56 and fails. Header information and allocation granularity can therefore change the answer even when the alignment condition itself is satisfied.[ref]
For integer addresses, the padding before the payload lies between0 and bytes. Splitting a chosen block can introduce another constraint: a leftover interval may be too small to hold a free record. A capacity calculation must consequently identify the actual header, alignment, rounding and remainder conventions rather than treating every raw free byte as payload.
Alignment padding bound 2026-11-05
The alignment padding bound limits the extra bytes needed to move an integer payload address to the next permitted memory alignment. Let be the first address after an allocated header, and let alignment require a multiple of a positive integer . With
the exact bound is . It applies to the earliest aligned start, not to arbitrary extra space an allocator may choose to reserve.
To prove the bound, write . The ceiling function gives , hence . Since is an integer number of bytes, . The endpoints can occur: an already aligned gives zero padding, while one byte beyond an aligned address gives . This is also the statement that is the least nonnegative residue of in modular arithmetic.
For an original example, , header size and block start give , and . The worst-case bound is attained. Starting at instead gives and . Identical header and payload sizes can therefore incur different allocation alignment padding at different addresses.
A sufficient address-independent reservation for a payload of bytes is , before any trailer, block rounding or minimum free-block size constraint. For , and ,47 bytes suffice under precisely that layout. A known starting address can require less: needs5 bytes of padding and a37-byte used prefix. Separating the payload from its metadata is the bookkeeping principle illustrated in OSTEP; the bound adds a worst-case alignment allowance.[ref]
These inequalities concern mathematical integers. An implementation using bounded address arithmetic must separately prevent integer overflow when adding the header, padding allowance or payload. A wrapped sum cannot be justified by a correct bound over unbounded integers.
Allocation alignment padding is the unused space inserted before an allocated payload so its address meets memory alignment. If a free extent starts at integer byte address , an allocation header consumes bytes, and payload addresses must be multiples of positive integer , the earliest permitted address and its padding are
Equivalently, is the least nonnegative residue of modulo . The alignment padding bound is . Already aligned payload starts have zero padding; adding a whole extra alignment unit in that case would waste space unnecessarily.
For an original example, let a free extent be , with and . Then , and bytes. A24-byte payload ends at40, so the used prefix occupies37 bytes:8 for the header,5 for padding and24 for data. The remaining interval has27 bytes before other block-rounding or minimum free-block size requirements are applied. This accounting distinguishes padding from header storage and from payload-size rounding.
The same header and alignment can produce different padding at another address: gives and . If the residues of were uniformly distributed over all16 possibilities, the mean padding would be7.5 bytes, obtained by averaging0 through15. An actual allocator can constrain its block starts, so that distribution is an explicit model assumption rather than a measured universal overhead.
Aligned free-block capacity must deduct this padding when testing whether a request fits. Allocation alignment padding can thus make two equally long free extents offer different usable capacities. OSTEP's separation of the allocated payload from its bookkeeping header is the basic layout issue behind this calculation; alignment adds the stated address constraint.[ref]