szn

Bug 405 — Resize reflow clones the entire grid + history + flat_cells scratch per width change from the session arena — nothing is ever reclaimed (interactive drags accumulate hundreds of MB)

405. Resize reflow clones the entire grid + history + flat_cells scratch per width change from the session arena — nothing is ever reclaimed (interactive drags accumulate hundreds of MB)

Severity: MEDIUM Status: ✅ RESOLVED

reflowCursorInternal builds a complete second copy of every logical line (history_limit + height rows × width × 16-byte Cell), plus flat_cells scratch (ensureTotalCapacity(process_limit * width)), all from the session arena. Arena frees only unwind the most recent allocation, and there is no arena.reset anywhere, so old lines and scratch are permanent. Worse: whenever hist_len > 0, process_limit = @max(process_limit, total) (:779-781) rebuilds all history even when only the bottom cursor line changed. With the default 2000-line history at 200 columns, each width change burns ~10 MB; a window-manager resize drag (dozens of events) multiplies that. Same class: auto-rename dupes last_foreground_name per fg-process change (server.zig:2925-2927) with an arena no-op free.

Fix: run reflow in a dedicated child arena (or scratch) reset after each resize, and limit the rebuild to lines that actually change width/wrap state.