Fixed Application Arena

PixelUI does not create Apps with new/delete. The ApplicationStack inside ViewManager reserves a fixed byte arena, and all live Apps are constructed in place following stack order.

ApplicationStack arena layout

App A and App B use only their actual object sizes. Alignment requirements determine the padding between them. Object bytes and metadata are separate: metadata records rollback positions and concrete destructors, so object boundaries do not need to be recovered from arena bytes.

Arena bytes, maximum alignment, and page depth are fixed configuration values listed in Resource limits.

Layout

1
2
3
4
5
arena begin
| App A | padding | App B | free space ... |
^ marker A ^ marker B ^ current offset

separate metadata: [pointer, marker, end offset, destroy thunk] x depth

Each push aligns the current offset to alignof(T), verifies that padding plus object bytes fit, and placement-constructs the object. Metadata is committed only after construction succeeds. Pop invokes the correct destructor through a type-specific destroy thunk and restores the previous marker.

Why a LIFO arena

  • Capacity and failure are predictable.
  • App objects do not fragment a heap.
  • Small Apps consume only their own size instead of reserving a maximum-size slot.
  • Reclamation needs no general allocator because page navigation is already LIFO.

The tradeoff is that only the top App can be destroyed; a page cannot be removed from the middle. The total size and alignment padding of all live Apps must fit in the arena.

Factory and custom construction

launch() uses the factory in AppItem to construct a concrete type inside the arena. See Launch AppLauncher for regular registration. Use a non-capturing thunk for special constructor arguments:

1
2
3
4
5
6
AppItem item = AppItem::make<MyApp>(
"My App",
iconBits,
[](void* storage, PixelUI& ui, void*) -> IApplication* {
return ::new (storage) MyApp(ui, fixedItems, fixedItemCount);
});

The thunk may construct exactly the declared concrete type in storage, or return null without constructing anything.

Measurements and target platforms

One Apple arm64 Debug measurement for v0.3.1-beta was ApplicationStack=4416, ViewManager=4608, and PixelUI=9216 bytes, including a 4096-byte arena. This is not a guarantee for an MCU ABI; measure again with the target compiler.

1
./build/tests/memory_metrics
最新文章
网站信息
文章数目 :
1
本站访客数 :
本站总浏览量 :
最后更新时间 :