← Back to section · Research & Analysis
Memory Footprints: The Third Dimension Benchmark Tables Hide
Server benchmarks rarely report stack and heap usage, yet memory is exactly the constraint that tops out before speed on constrained devices. This article maps the memory profiles of the PQC families: intermediate buffers in lattice signatures, the tree-traversal trade-off in hash-based signatures, and the residency cost of large code-based public keys.
There is a systematic silence in performance discussions: benchmark tables report cycles and bytes, but rarely how much memory an operation actually occupies while running. On servers this is harmless — memory is counted in gigabytes, and a few dozen extra kilobytes go unnoticed. Move the same algorithms onto a microcontroller with tens to hundreds of kilobytes of RAM, and memory steps out of the background into the lead role: what tops out first is not speed but stack. This article lays out each family’s memory profile on its own.
The lattice family: intermediate buffers set the peak
The memory peak of lattice schemes is not in the key material itself but in the intermediate state of the computation. ML-DSA signing must simultaneously hold the matrix expanded from the seed, the mask vector y, the product w, and the polynomial sets before and after packing; the accumulated intermediate buffers reach the order of tens of kilobytes, and the peak sits on the signing path. The verification path needs neither the mask nor the rejection loop’s intermediates and is visibly leaner. ML-KEM is similar: encapsulation and decapsulation must reserve buffers for reconstructing the matrix A row by row — though A can be generated row-wise and discarded after use, leaving generous room for time–memory scheduling. A common implementation optimization targets precisely this peak: reusing a single buffer, converting in place between the NTT and coefficient domains, and parking temporary polynomials in fixed stack slots. Consequently, the memory profiles of the same algorithm across implementations can differ by a factor of several — which is why embedded benchmarks such as pqm4 report stack usage alongside speed.
Hash-based signatures: small state and the traversal trade-off
SLH-DSA’s key material is negligible: the secret key is essentially two seeds, and the public key is a root node. But its signing process evaluates a tall hypertree layer by layer, and the traversal strategy sets the exchange rate between memory and time. Caching all intermediate nodes minimizes hash invocations but reserves substantial buffer space for a multi-layer tree; storing only the nodes on the current path minimizes memory at the price of repeatedly recomputing subtrees. Part of the difference between the s and f variants in the parameter table (smaller signatures versus faster signing) comes from different points chosen along exactly this trade-off curve. Stateful hash-based signatures (XMSS/LMS) raise a separate memory topic: their secret state grows with the signature count and must be reliably protected against rollback, so the state’s cost lives not in RAM but in persistent media and operational discipline — here the memory profile extends into a state-management profile.
The code-based family: the long-term cost of key residency
Classic McEliece’s memory problem is not a computation peak but residency: a public key of roughly 261 KB to 1.36 MB, if held permanently in RAM, is an outright disqualifying size for constrained devices; if kept in external storage and loaded on demand, every session first pays an I/O and integrity-checking bill. The decapsulation side also carries non-trivial working memory during systematic-matrix decoding, but not on the same level as key residency. For such schemes, the right question about the memory profile is not “what is the peak” but “in what form, on what medium, and held by whom does the key material live” — a systems-design question rather than an implementation-optimization one.
Do not forget code size: the other column, on ROM
The memory profile has a sibling that is often swept vaguely under “memory”: code size — the volume an implementation itself occupies in flash or ROM. Constrained devices count flash in hundreds of kilobytes too, and a PQC implementation compiled with several parameter sets, several algorithms, and their respective optimized paths inflates quickly. Sharing the lower layers is the main compression lever: the Keccak permutation is reused across KEMs, signatures, and hash functions, and NTT kernels are shared within a family, so a well-built library makes the marginal code cost of a second algorithm far lower than the first. Conversely, hand-assembled fast paths for a single platform multiply code volume, and speed trades against code size once again. The reason pqm4 reports code size alongside stack and cycles is precisely that on constrained devices all three are hard constraints — omit any one column, and selection may discover only at deployment time that the firmware does not fit.
How memory should enter benchmarks
Three methodological conclusions follow. First, report peak memory, not averages, and state whether key material and I/O buffers are included; figures under different conventions are not comparable. Second, report stack and heap separately: on embedded targets, stack overflow is silent memory corruption, far more dangerous than a failed heap allocation, and many embedded implementations deliberately place buffers in static storage for exactly this reason. Third, memory and speed must be reported in the same table, because the two are so often exchanged against each other: memory-frugal implementations are usually slower, and fast ones usually eat more buffer. A benchmark that reports speed alone hides the exchange. The pqm4 practice of publishing cycles, stack, and code size together on Cortex-M4 should be the minimum standard for constrained-scenario benchmarks.
Fourth, dynamic allocation must be declared separately. Many embedded implementations deliberately avoid malloc throughout, placing buffers in static storage or fixed stack slots, because heap fragmentation and allocation failure are independent risk sources on long-running devices; an implementation that runs flawlessly on a desktop may be unportable to a device precisely because it depends on dynamic allocation. Stating the static/stack/heap composition of a memory profile matters as much as stating the peak.
Summary
Memory is the third dimension of the PQC performance profile, alongside cycles and bytes, and on constrained devices it is usually the dimension that tops out first. Lattice schemes peak in their intermediate buffers; hash-based signatures hinge on traversal trade-offs and state management; code-based schemes struggle with public-key residency. If a benchmark has no memory column, assume it was filtered out by scenario — and if your scenario is outside that filter, that column of numbers needs measuring yourself, not assuming away.
References
- The pqm4 benchmark framework’s reporting conventions for stack usage and code size on Cortex-M4
- FIPS 205 — the structural differences between SLH-DSA parameter-set variants (s/f)
- RFC 8391 (XMSS) and RFC 8554 (LMS) — provisions on state management for stateful signatures
Tags: Memory FootprintEmbeddedStack UsagePerformance Profile