szn

Bug 304 — renderToDisplayClient allocates pane_border format strings on every render

304. pane_border format strings allocated per-pane per-client every render

File: src/server/server.zig:2737-2780 Severity: MEDIUM Status: ✅ FIXED

In renderToDisplayClient, for each pane in each display client:

  1. A format_mod.Context is created and destroyed (heap allocation)
  2. format_mod.expand is called, which allocates the expanded string
  3. The expanded string is stored in pane_border_owned and freed at end of render

This happens even when the format string is static (e.g. default “#I”) and produces identical output every render.

With 4 panes and 2 display clients, that is 8 context allocations + 8 expand allocations per render.

Fix: Cache the expanded border format per pane. Store expanded_border: ?[]const u8 on Pane (owned, freed on deinit). Only re-expand when the option changes (track via a generation counter or dirty flag on the option). The context can also be reused — store a single Context on Server and clear it per-use instead of creating/destroying.