Memory Allocation for Constant-Bounded Programs
Vinícius Silva, Kael Soares, Márcio Costa e Fernando Magno Quintão Pereira
Key points
From the paper's conclusion- We show that constant boundedness enables a tight, polynomial-time approximation of optimal stack usage by viewing control flow as a tree and applying a tree-scan allocation strategy augmented with memory defragmentation.
Abstract
This work studies memory allocation for constant-bounded programs, whose execution length is syntactically limited for all inputs. Examples of such programs include verified kernel extensions, cryptographic routines, and fixed-shape machine-learning models. We show that constant boundedness enables a tight, polynomial-time approximation of optimal stack usage by viewing control flow as a tree and applying a tree-scan allocation strategy augmented with memory defragmentation. Our approach guarantees memory usage bounded by the maximum live memory plus, at most, the size of the largest buffer, and is optimal when in-place swapping is permitted. We deploy the proposed allocator in two scenarios. First, in an Elixir-to-eBPF compiler, as a spiller that optimizes stack space. Second, as a static heap allocator for bounded MLIR programs using the Structured Control-Flow dialect. Results demonstrate stack reductions exceeding 90% on real eBPF workloads and show that, even under aggressive code expansion, defragmentation is rarely required and memory usage remains a small fraction of that required by naive allocation strategies.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Tight Bounds for Memory Allocation With and Without Request FragmentationarXiv · 2026
- CrossCheck II: A Compiler Plugin for Certified Cost Bounds of Real-Time C and C++ Code, and its EvaluationarXiv · 2026
- Blame-aware Recomposition for Secure Compilation Proofs of Low-Level Compartment IsolationarXiv · 2026
- SkillEffect: Checked Lowering for Memory-Bounded Agent ToolsarXiv · 2026
- Two-Sided Amortized Resource Analysis: Verifying Resource Lower Bounds via Ill-TypingarXiv · 2026
- Memory Compression for High-Fanout Agent SandboxesarXiv · 2026