Nebble is engineered for maximum stability and performance on Pebble's extremely limited hardware (as little as 24KB RAM on Aplite). A core pillar of this design is the Zero-Heap Architecture.
In a typical Nim or C application, dynamic strings and sequences are allocated on the heap using malloc. On Pebble, this presents several risks:
Nebble provides high-level abstractions that look and feel like modern Nim but operate entirely on the stack or in static storage.
Instead of the dynamic string type, Nebble uses FixedString[N]. This is a stack-allocated buffer with a fixed maximum capacity.
var msg: FixedString[32] # 32 bytes pre-allocated on the stack
To format strings without sprintf or Nim's $ (which allocates), Nebble provides the f macro. It performs type-to-string conversion at runtime into the fixed buffer.
var count = 42 var status: FixedString[32] status.f("Steps: ", count, "!") # Zero heap usage! textLayer.text = status # Sets the layer text safely
Nebble uses Nim's ARC (Automatic Reference Counting). Unlike a traditional Garbage Collector, ARC doesn't have a "stop-the-world" phase or a background thread. It inserts deterministic free/destroy calls at compile-time. Combined with our Ownership Model, this ensures that even when we do use heap (like for AppSync buffers), the cleanup is instant and predictable.
Nebble APIs are audited to avoid seq[T]. Where Pebble requires arrays of data (like for Animation groups or VibePattern durations), Nebble uses stack-allocated arrays or varargs that compile down to C arrays.
To maintain the performance benefits of Nebble, follow these rules:
By following these patterns, your Nebble app will have a perfectly flat memory profile, zero fragmentation, and maximum battery efficiency.