tiny.alloc
Overview · API · Code relationships · Verification · Audit
Overview
The package decides which allocator a program's long-lived storage comes from, and it holds the byte ceiling a caller can put in front of an allocator. The single allocator a program's long-lived storage comes from, chosen when the program is compiled, is the process allocator. The parts of a program that live as long as the process take the storage they need while it starts up.
The process sits in one stage of its life at a time, its phase, one of initialization, steady state, or teardown. The startup stage, in which allocation is expected, is initialization. The call that ends initialization and moves the process to steady state is the seal, executed by sealProcessAllocatorPhase. The stage after the seal, in which an allocation counts as a violation, is steady state. One allocator operation that arrived in a phase which forbids it is a violation.
The build setting that decides what happens to a violation, one of off, observe, or seal, is the process phase mode. Under the seal build setting, an allocation, a resize, or a remap that arrives after the seal panics and is refused, and a free is refused the same way. Under the observe setting, the same operation is counted, the return address of the call that violated is kept as the violation site, and the operation goes through. A free during teardown counts as no violation, so a program can release its startup storage.
The allocator that checks a byte ceiling of its own before asking the allocator behind it for anything is the limit allocator, implemented as LimitAllocator. That ceiling bounds how far the memory behind it can grow. LimitAllocator reports its own refusal, AllocationLimitExceeded, apart from the backing allocator's OutOfMemory, so a caller can tell a configured ceiling from a machine running out of memory.
Definitions
Actions
Public operations.
testIntegrationAllocatorbeginProcessAllocatorTeardown: Opens the teardown phase, so a free that follows counts as no violation and a caller can release the storage taken at startup.diagnosticAllocatorConfigprocessAllocatorPhaseViolationSitesprocessAllocatorPhaseViolationssealProcessAllocatorPhase: Marks the moment startup is over, after which the package can tell a startup allocation from a later one: it ends the initialization phase of the process allocator.diagnosticAllocatorReportlongLivedProcessAllocator: Returns the allocator for storage that lives for the whole process.processAllocatorPhaseworkerAllocatorwritePhaseReportinteractiveSessionAllocator: Returns the allocator for storage that stays valid for the session around the call.standaloneProcessAllocatortemporaryScratchAllocatorthreadedIoAllocator
Types and contracts
Public types and contracts.
LimitAllocatorLockedAllocatorPhaseBoundaryStateProcessAllocatorFinishProcessAllocatorOwnerProcessPhaseModeTestAllocatorModePhaseBoundary
Values and defaults
Public values and defaults.
Code relationships
Direct static dependencies extracted from parsed source by semantic graph analysis.
Uses: tiny.bumpalo, tiny.deadalloc, tiny.gpalloc, tiny.sys
Used by: tiny.glom, tiny.http, tiny.profiling, tiny.smg, tiny.tldr
Verification
No verification records are cataloged for this module in this build.
Audit
| Evidence | Value |
|---|---|
| Source | lib/alloc/src/root.zig |
| Definitions | 4 of 27 documented |
| Members | 0 of 0 documented |
| Public names | 27 API, 33 indexed |
| Version | 26.7.0 |
| Revision | daab053ee433 |
| Unresolved targets | 3 |