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]
Free list 2026-11-05
A free list records free memory regions or reusable allocation units so an allocator can find storage for a request. In a variable-size pool, a record typically needs a block's location and length. A linked implementation also stores a link to another free record; these records can occupy the free blocks themselves. The term can also describe the allocator's logical inventory when its search structure is more elaborate than one linked chain.[ref]
For an illustrative inventory of free extents of16,32 and48 bytes, a24-byte request cannot use the first extent but can use either later one, before metadata and alignment are counted. Choosing the32-byte extent leaves an8-byte remainder if split exactly. Whether that remainder can become a free-list entry depends on the minimum free-block size.
Suppose an explicitly hypothetical in-block free record needs an8-byte length field and an8-byte next-link field. Its16-byte metadata cannot fit in that8-byte remainder. The allocator can instead give the request the entire32-byte block, leaving8 bytes of internal fragmentation, or choose another layout or block. Metadata placement is therefore part of allocation capacity, rather than an afterthought.
When a block is returned, memory block coalescing can combine it with adjacent free neighbors and update the inventory. Address order can make adjacency checks convenient; other orderings can favor allocation searches. A list that contains enough total free bytes may still lack one sufficiently large extent, producing external memory fragmentation. The search policy, split rule, metadata layout and coalescing policy jointly determine which requests succeed.
Minimum free-block size 2026-11-05
The minimum free-block size is the smallest extent that an allocator's representation can retain as an independent free record. It depends on where the allocator stores a region's size, links and other metadata, as well as memory alignment. A region may contain unused bytes yet be too short to enter the free list. OSTEP demonstrates why allocator metadata must be counted: free records can be embedded inside the free regions themselves.[ref]
For a hypothetical allocator, let a free record need an8-byte size field and two8-byte links. Its raw metadata requires24 bytes. If all block lengths are multiples of16 bytes, its minimum independently representable size is
The exact fields and sizes are illustrative. An allocator with separate metadata, a singly linked record or another block granularity can have another minimum.
Suppose the same allocator uses an8-byte allocated-block header. An8-byte payload plus that header would occupy16 bytes before enforcing the minimum. Reserving32 bytes ensures that this block can later become an independent free record. Extra allocation space of this kind contributes to internal fragmentation. The allocator might instead use a distinct representation for tiny blocks, so the formula is a design constraint for the stated representation rather than a universal allocation rule.
A proposed split also needs to respect the minimum. Taking80 bytes from a96-byte extent leaves16 bytes, an unsplittable free-block remainder under this layout. Giving the caller the full96-byte extent avoids making an invalid free record but consumes extra storage. Taking32 bytes would leave64, which can be retained. Memory block coalescing can later join adjacent returned extents, but the allocator must have a valid way to represent each extent until that happens.
An unsplittable free-block remainder is the positive suffix left by a proposed allocation that is too small to retain as a valid independent free list record. Its size is below the allocator's minimum free-block size. The region still contains unused bytes, but the chosen representation cannot manage it as a separate free extent. The issue arises because free-region metadata can occupy the regions themselves.[ref]
Let a chosen block have size , let the proposed allocated extent after header/alignment rounding be , and let the minimum free size be . With remainder , an allocator that absorbs an undersized suffix uses
This is one possible policy, not a mandatory allocator interface. The absorbed suffix adds bytes of internal fragmentation beyond the bookkeeping and rounding already included in .
For an original example, take bytes, an8-byte allocated header,16-byte block granularity and bytes. A56-byte payload gives , leaving a representable32-byte free block. A57-byte payload instead gives , leaving an unusable16-byte suffix. Absorbing it reserves all96 bytes. Increasing the request by just one byte has therefore increased this allocation's occupied extent by32 bytes.
If and all extents are multiples of a granularity , a positive absorbed suffix is at most bytes. Without that granularity condition, the general integer-byte bound is . Choosing another free block or another representation can change the tradeoff. Later memory block coalescing can recover adjacent space when allocations are returned, but it does not make an invalid intermediate free record representable.