szn

Bug 291 — decrementAltGridRef is dead code — alt-screen sixel refcounts never decremented

291. decrementAltGridRef is dead code — alt-screen sixel refcounts never decremented

File: src/screen.zig:466–479 Severity: MEDIUM (dead code / refcount drift) Status: ✅ FIXED — useAltScreen(false) now walks the alt grid’s lines and releases refcounts before deinit; the dead decrementAltGridRef helper was removed. Regression test: place a sixel on the alt screen, exit it, verify refcount drops to 0.

decrementAltGridRef is defined but never called anywhere. Erase/overwrite paths that operate on the alternate screen only use decrementMainGridRef / decrementLineRefs, which act on self.grid — so sixel marker refcounts on the alt grid are never released when alt-screen cells are overwritten (e.g. eraseDisplay(2) on the alt screen). Alt-screen refcounts drift upward, eventually making slots permanently “referenced” and forcing Step-4b force evictions.