﻿# TFLite Micro arena accounting: activation storage is only part of the budget

Budget a microcontroller tensor arena from the actual allocator and kernels. Separate planned reusable storage, persistent metadata, alignment overhead and memory outside the arena.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/edge-tflite-micro-arena-allocation-ledger/
Language: en

## The model fits flash but tensor allocation fails

A sensor classifier’s model file fits its firmware image, yet interpreter initialization cannot allocate tensors. Estimating RAM from the file size or only the visible input and output misses the interpreter’s working storage. Start an arena ledger for the actual model, kernel set and runtime build. Keep the model’s stored representation separate from the mutable resources required to execute it. A successful firmware link does not establish that the chosen arena can satisfy initialization and the intended inference path.

## The planner uses lifetimes rather than a naive sum

The [MicroAllocator implementation](https://raw.githubusercontent.com/tensorflow/tflite-micro/main/tensorflow/lite/micro/micro_allocator.cc) passes buffer sizes and lifetimes to a memory planner and plans scratch buffers with model storage. Non-overlapping lifetimes can permit reuse under the selected planner. Summing every intermediate as simultaneously live can overestimate one part of the requirement, while ignoring scratch or metadata can underestimate another. Preserve the actual planned layout and allocator outcome instead of choosing whichever simplistic estimate makes a desired board appear sufficient.

## Persistent objects need their own categories

The allocator also creates metadata for evaluation tensors, operators and registrations, with persistent resources including variable buffers and kernel data where required. These do not disappear merely because activations are reused. The [recording allocator](https://raw.githubusercontent.com/tensorflow/tflite-micro/main/tensorflow/lite/micro/recording_micro_allocator.cc) exposes named categories and distinguishes requested bytes from consumed bytes with alignment overhead. Use these categories to locate an increase after a model or kernel change. Do not equate a convenient activation-only subtotal with the complete arena total.

## An arena report is not whole-firmware peak RAM

Account separately for stacks, sensor acquisition buffers, application state and any platform-specific resources outside the interpreter’s recorded arena. Also note when instrumentation observes the allocator, because a final report need not describe every transient condition or uninstrumented subsystem. A total-board claim requires a boundary covering those resources under the intended execution pattern. Keep recording-build overhead explicit when comparing a diagnostic interpreter with production. Source-level accounting facilities do not supply a new empirical RAM measurement for a particular board.

## Propose a build-specific memory fixture

For a harmless classifier, record the exact model, runtime, kernels, configured arena capacity and allocation status. Retain category reports after the relevant setup and exercise representative valid inputs through invocation. Compare a single deliberate model or kernel change, then update the external firmware ledger. Acceptance requires successful allocation and correct outputs within the declared combined budget. No firmware was flashed or allocator executed here; the procedure describes evidence to collect, not a fabricated minimum arena size or capacity benchmark.

## Retain the measurement boundary

[Embedded inference benchmark boundaries](/journal/unpu-bench-initialization-io-frequency-normalization-energy-sampling/) explain why firmware and accelerator categories differ. [Reproducible software stacks](/journal/software-stack-reproducibility/) explain why selected kernels and builds belong in the record. Arena accounting adds a precise interpreter-level view, not a universal conversion from model parameters to RAM. Report planned and persistent components, observed phase and external allocations so a deployment decision can be reviewed without substituting flash capacity or model-file size for runtime evidence.
