szn

Bug 306 — collectPaneBounds allocates ArrayList on every call

306. collectPaneBounds does heap allocation per pane per client per render

File: src/server/server.zig:1957-1980 Severity: LOW Status: ❌ FALSE POSITIVE

fn collectPaneBounds(...) {
    switch (node.*) {
        .leaf => |pane| {
            try result.append(self.allocator, ...);  // heap allocation per pane
        },
        ...
    }
}

Called from renderToDisplayClient once per display client per render. With 4 panes and 2 clients: 2 calls, each allocating 4 PaneBounds structs.

Also called from findDirectionalNeighbor (line 1983) which allocates a local ArrayList every time a directional pane selection is made.

Fix: The bounds_buf on DisplayClient is already reused (clearRetainingCapacity). collectPaneBounds itself doesn’t need to change — it writes into the caller’s buffer. However, findDirectionalNeighbor allocates a local ArrayList every call. Cache the bounds on the Window struct and invalidate on layout change.