memory-freertos

Manage ESP32 heap, PSRAM, and FreeRTOS task stack usage.

5|2|Updated Dec 26, 2025
One-click install
npx skills add https://github.com/mirkosertic/Megahub --skill memory-freertos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: memory-freertos
Source: https://github.com/mirkosertic/Megahub/tree/main/.claude/skills/memory-freertos
Command: npx skills add https://github.com/mirkosertic/Megahub --skill memory-freertos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you reason about memory pressure, stack limits, and concurrency hazards in the Megahub ESP32 firmware so you can avoid crashes, deadlocks, and hidden performance regressions.

Core Features & Use Cases

  • Heap and PSRAM budgeting: Track free heap and PSRAM across startup stages and Bluetooth lifecycle events.
  • Task and stack safety: Use known FreeRTOS task stack high-water marks to size work safely and prevent overflow.
  • Concurrency guardrails: Apply timeout-based mutexes, queues, and semaphores for BLE callbacks, HID events, and inter-task communication.
  • Use case: When adding a new Lua feature or BLE handler, check its memory impact, choose the right task context, and keep the BT stack healthy.

Quick Start

Ask for a memory-aware review of the change and include the affected task, expected allocations, and any Bluetooth or Lua callbacks involved.

Frequently Asked Questions about memory-freertos

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage ESP32 FreeRTOS task stack sizes to prevent overflow?

To manage ESP32 FreeRTOS task stack sizes, monitor high-water marks to determine safe allocation limits and prevent overflow. Track heap usage across startup stages and apply timeout-based synchronization to avoid crashes and deadlocks.

Why does my ESP32 crash during Bluetooth callbacks with concurrent Lua tasks?

ESP32 crashes during Bluetooth callbacks often stem from heap exhaustion or concurrency hazards. Apply timeout-based mutexes, queues, and semaphores for BLE HID events and inter-task communication to keep the BT stack healthy and avoid deadlocks.

What is the best way to budget heap and PSRAM on ESP32 constrained hardware?

The best way to budget heap and PSRAM on ESP32 is tracking free memory across startup stages and Bluetooth lifecycle events. This approach requires awareness of PSRAM availability and allocation impacts to maintain firmware stability.

How do I add a new Lua feature to ESP32 without causing memory pressure?

To add a Lua feature without causing memory pressure, request a memory-aware review including the affected task, expected allocations, and any Bluetooth callbacks. Choose the appropriate task context and verify heap impact before integration.

Does FreeRTOS inter-task communication require timeout-based synchronization on ESP32?

FreeRTOS inter-task communication on ESP32 requires timeout-based synchronization to prevent deadlocks. Apply timeout-based mutexes, queues, and semaphores for BLE callbacks and HID events to ensure safe concurrency on constrained embedded hardware.

What are the limitations of running Bluetooth and Lua runtime simultaneously on ESP32?

Limitations of running Bluetooth and Lua simultaneously on ESP32 include heap exhaustion and concurrency hazards from constrained memory. Monitor task priorities, stack high-water marks, and PSRAM availability closely to prevent hidden performance regressions and crashes.