esp32-heap-discipline

Solid

Memory-allocation discipline for AgentDeck ESP32 firmware (esp32/). Use whenever writing or reviewing firmware code that allocates — new / malloc / ps_malloc / heap_caps_alloc / std::vector / std::string / String / a buffer / a cache / anything held across a render loop. Covers the PSRAM-vs-no-PSRAM board split, the allocation decision order, fragmentation avoidance, the makeUniqueNoThrow / ScopedCleanup helpers, the PROTOCOL_MAX_MSG_BYTES JSON guard, and the heap diagnostics (logHeap / [PERF] freeblk).

AI & Automation 165 stars 29 forks Updated today MIT

Install

View on GitHub

Quality Score: 88/100

Stars 20%
74
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# ESP32 Heap Discipline Memory rules for `esp32/` firmware. Adapted from crosspoint-reader's `heap-discipline` skill to AgentDeck's multi-board reality. This is the procedure you run while writing firmware and the gate before handing it back. ## The board split — know which world you're in AgentDeck firmware targets two memory regimes. Check the board macros first. - **PSRAM boards** — `BOARD_BOX_86`, `BOARD_IPS35`, `BOARD_AMOLED`, `BOARD_IPS10` (ESP32-S3 / -P4, 8–32MB PSRAM). Large canvases/caches go in PSRAM (`ps_malloc` / `MALLOC_CAP_SPIRAM`). **But** per-pixel / LVGL draw buffers and PPA rotation buffers must stay in **internal SRAM** (`MALLOC_CAP_INTERNAL`): PSRAM writes are ~30× slower, so a PSRAM draw buffer makes every widget render crawl (see the IPS10 rationale in `esp32/src/ui/display.cpp`). Plenty of total RAM here; the constraint is *write latency and internal-SRAM headroom*, not bytes. - **No-PSRAM boards** — `BOARD_TTGO` (classic ESP32, ~160KB heap), `BOARD_ESP32_C6_147` (single-core RISC-V), `BOARD_LED8X32` (TC001). This is crosspoint's world: every allocation matters and **fragmentation, not total usage, is what kills the device.** Free heap can read fine while the largest free block is too small for the next alloc. Optimize for not leaving holes. The canvas/buffer code already encodes this split (`renderer.cpp::init` uses static pre-allocated buffers on TTGO/C6 and `ps_malloc`+SRAM fallback elsewhere). Match the existing pattern; d...

Details

Author
puritysb
Repository
puritysb/AgentDeck
Created
5 months ago
Last Updated
today
Language
C
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Listed

memory-contexts

Allocate memory in PostgreSQL backend C — pick the right MemoryContext and use palloc / palloc0 / pstrdup / psprintf correctly. Covers CurrentMemoryContext / TopMemoryContext / per-query / per-tuple / ExecutorState context choice, MemoryContextSwitchTo discipline, the OOM-throws-ereport contract (no NULL checks), pfree vs MemoryContextReset vs MemoryContextDelete, the AllocSet vs Slab vs Generation vs Bump context-type cheat sheet, and leak-scoping in long-running backends. Use whenever a PG patch or extension calls palloc / palloc0 / MemoryContextAlloc, creates or switches a MemoryContext, picks AllocSet vs Slab vs Generation vs Bump, or debugs a context-shaped leak. Skip for plain malloc / free / jemalloc / mimalloc / tcmalloc, JVM / Go / .NET GC tuning, Rust Box / Rc / Arc / lifetimes, shared_buffers / work_mem production tuning, valgrind / heaptrack on non-PG programs, and C++ smart pointers.

0 Updated 4 days ago
matejformanek
AI & Automation Solid

systems-programming

Systems programming from memory management through networking. Covers memory models (stack vs heap, manual allocation, garbage collection, ownership/borrowing), concurrency (threads, mutexes, channels, async/await, actor model, data races vs race conditions), operating system concepts (processes, virtual memory, page tables, system calls, file descriptors, signals), compilation (lexing, parsing, code generation, linking, static vs dynamic libraries), networking fundamentals (TCP/IP, sockets, HTTP, DNS, TLS), and the hardware-software boundary (caches, cache lines, false sharing, memory-mapped I/O). Use when working with low-level code, diagnosing system-level bugs, understanding performance characteristics, or bridging between high-level languages and machine behavior.

69 Updated 1 weeks ago
Tibsfox
AI & Automation Listed

memory

Project memory architecture across sessions — the runtime's native instruction-file hierarchy and cross-session memory, discipline (<200 lines/file, a thin index + lazy topic files, tiered loading for quality), a pre-compaction checkpoint, pointers to routines/loop. Use when you're organizing project knowledge/notes, setting up memory, or the context is growing.

3 Updated today
BilBBBOBaggins