Repository navigation
Description
Summary
When the sidebar runs for an extended period, the tmux server process (not the sidebar process) grows its memory monotonically and without bound — on my machine ~2 GB/day. Because every new-window/split-window makes the tmux server fork(), a bloated server makes new-pane creation extremely slow (sub-second → multi-second). The leaked memory is not reclaimed by closing the sidebar pane(s); only restarting the tmux server (kill-server) frees it.
I isolated this to the sidebar with an A/B test (below): an identical tmux server with the same driver but no sidebar stays flat.
Environment
- tmux-agent-sidebar 0.10.1 (commit
b56a47a) - tmux 3.2a
- Pop!_OS 22.04 LTS, kernel
Linux 7.0.9 x86_64 - Usage:
@sidebar_auto_create off, sidebar toggled manually, watching Claude Code / Codex agent panes - Affected server uptime when measured: ~5d 17h
Symptom
new-window / split-window take ~760 ms (well over 1 s once the login shell is layered on). A trivial tmux command (display-message) on the same server is ~4 ms, so the server's event loop is fine — the cost is in spawning a pane.
Root cause
The tmux server had RSS ≈ 2.1 GB + ~9.7 GB swap (~11.8 GB total) after ~6 days. But the actual live data is tiny:
total scrollback across all 11 panes = 24.8 MB (history-limit 10000)
paste buffers = 0
So ~11.8 GB is unaccounted-for heap. Creating a pane forks that giant address space (copying page tables, faulting swapped pages) → the ~760 ms. A fresh tmux server with my identical config forks a new window in 14 ms, so it is not the config or plugin load — it is accumulated server memory.
Reproduction (A/B isolation)
Isolated tmux server (-L), same driver (cycle window focus + nudge the sidebar to refresh), 3000 cycles, measuring the server process RSS:
| start | after 3000 cycles | |
|---|---|---|
| with sidebar attached | 4.0 MB | 4.7 MB (monotonic) |
| control, no sidebar | 3.9 MB | 4.1 MB (flat) |
Longer run (12000 cycles) shows clean linear growth: 4.0 → 5.1 → 6.2 → 7.4 MB.
Closing panes does not reclaim it
After the 12000-cycle run peaked at 7.4 MB:
PEAK with sidebar still open: RSS = 7.4 MB
AFTER killing the sidebar pane: RSS = 7.4 MB (0 sidebar processes left)
AFTER closing all but one window: RSS = 7.4 MB
RSS does not drop at all — the leak is in the persistent server process, so only tmux kill-server returns it to the OS.
Suspected area
The growth tracks the sidebar's refresh loop (per #46 it polls every ~2 s, and it capture-panes agent panes each cycle). Something in that per-refresh interaction with the tmux server accumulates server-side memory over time. Worth checking the capture-pane / poll path (src/tmux/query.rs, src/cli/capture/) and whether anything created server-side (buffers/options/hooks) isn't cleaned up — though I confirmed paste buffers were 0, so it may be a tmux-side allocation triggered by a specific repeated command.
Possibly related
- macOS 26.4.1 kernel panic (os_refcnt: overflow @refcnt.c:68) after ~20 days uptime, task = tmux-agent-sidebar #66 (kernel panic "os_refcnt overflow" after ~20 days uptime, task = tmux-agent-sidebar) — also a long-uptime resource-accumulation signature, possibly the same underlying growth.
gh pr viewpolled every 2s per sidebar consumes significant GitHub GraphQL quota #46 (sidebar polls every 2 s) — establishes the high-frequency polling that drives the accumulation.
Happy to run further diagnostics (I have a repro harness) or test a patch.
Activity
trevnorris commentedon Jun 10, 2026
Confirmed still present on v0.12.0 (latest).
Upgraded 0.10.1 → 0.12.0 and re-ran the same isolated A/B harness. (Note: the prebuilt
tmux-agent-sidebar-linux-x86_64asset requiresGLIBC_2.39; on glibc 2.35 it won't run, so I built 0.12.0 from source with Rust 1.96.) The tmux server memory growth is unchanged:Same ~0.25 MB / 1000-refresh monotonic growth; the no-sidebar control stays flat. So the leak is not fixed in v0.12.0.
For reference, restarting the affected real server dropped it from 1,841 MB RSS (+ ~9.7 GB swap) → 3.9 MB, and
new-windowlatency from ~760 ms → 6 ms, confirming the slowness was the bloated server'sfork()cost.hiroppy commentedon Jun 10, 2026
@trevnorris thank you for reporting and investigation! I didn't notice the memory issue. If you allow to fix this issue, I'm really happy but I don't want to spend your time if it has deep issue 🙇 anyway, let's understand your investigation
my agent's memo
Details
trevnorris commentedon Jun 11, 2026
Thanks for the info. I'll attempt to update my tmux locally and see if that resolves it.
RayShark commentedon Jun 18, 2026
PR #103: #103
Fixes issue #85 by removing
#{q:...}from the hot refresh path and sanitizing the pane values that round-trip through the raw query path.Verified the query-path tests and release build.