返回 Skill 列表
extension
分类: 开发与工程无需 API Key

PicoRuby Development Constraints

文档记录了PicoRuby在ESP32上的内存限制和标准库约束。在为ESP32硬件编写代码或设计PicoRuby应用程序的功能时,请参考此文档。

person作者: jakexiaohubgithub

PicoRuby Development Constraints

Memory constraints and stdlib limitations for ESP32 PicoRuby development.

Memory & Runtime Limits

  • Total heap: 520KB (strict limit)
  • Nesting depth: Avoid deep recursion; prefer iterative solutions
  • String handling: Pre-allocate when possible; avoid repeated concatenation
  • Arrays: Use fixed-size when known; minimize dynamic growth during tight loops

PicoRuby vs CRuby

| Feature | PicoRuby | CRuby | |---------|----------|-------| | Gems | ❌ No bundler/gems | ✅ Full ecosystem | | stdlib | Minimal (R2P2-ESP32 only) | Complete stdlib | | Memory | ~520KB heap | GB+ available | | GC | Simple mark-sweep | Complex generational | | Float math | ⚠️ Limited precision | Full IEEE 754 |

PicoRuby-safe stdlib

Available:

  • Array#each, #map, #select (avoid #each_with_index in tight loops)
  • Hash (simple key-value)
  • String (basic methods, avoid regex for embedded)
  • Time (limited; ESP32 time depends on system clock)
  • File (via R2P2-ESP32 abstraction)

Unavailable:

  • Regex (use string matching instead)
  • Threads (single-threaded runtime)
  • Fiber/Enumerator (complex control flow not needed)