Skip to main content

heap-discipline

ESP32-C3 allocation discipline. Use when changing allocation size/failure handling, buffer or cache lifetime, or hot-path container growth.

来源信息

仓库
crosspoint-reader/crosspoint-reader
最近来源活动
2026年10月11日 10:57
检测到的 SKILL.md 语言
英语
星标
8,520
Forks
2,125

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
heap-discipline
description
ESP32-C3 allocation discipline. Use when changing allocation size/failure handling, buffer or cache lifetime, or hot-path container growth.
# Heap Discipline Use the selected board's [resource budget](../../rules/hardware-resources.md) and the [checked-allocation contract](../../rules/coding-standards.md#heap-buffer-allocation). Budget peak coexistence and largest required blocks, not just final free bytes. ## Allocation decision procedure Choose the first option meeting size, ownership, and lifetime requirements: 1. Local bounded storage within the stack budget: use a plain array/struct. 2. Immutable data: use static const/constexpr storage; verify placement when material. Cache-disabled paths need accessible internal RAM. 3. Repeated activity work: allocate once, retain and reuse through its lifetime; cleanup follows [activity ownership](../../rules/ui-activities.md#activity-lifecycle-and-memory-management). 4. Other fallible storage: use checked `makeUniqueNoThrow` ownership. 5. C/SDK ownership transfer: raw allocation only under the checked-allocation contract, with the receiving owner and matching deallocator identified. ## Check the complete working set Apply the [resource protocol](../../rules/hardware-resources.md#the-resource-protocol) to container growth, strings, stack, and persistence. Reuse existing buffers before adding storage. Full-screen work follows [framebuffer ownership](../../rules/architecture-hal.md#framebuffer-ownership); SD/vector arenas follow [font-cache ownership](../../rules/ui-activities.md#runtime-fonts-and-cache-ownership). Preserve `HalMemory::allocatePsram()`'s no-internal-RAM-fallback contract. For each new allocation, state worst-case bytes, peak coexistence, lifetime, placement, and why stack/static/reuse cannot meet the requirement. Verify failure propagation and cleanup, including retained parent activities and cache arenas. **Done when:** every allocation has a bounded budget and owner, checked failure handling, matching cleanup, and no avoidable repeated allocation in a hot path.
在 GitHub 查看