GeezerVison is showing github.com — Long-lived opencode serve grows with every repo it serves; recycle it when idle · Issue #1923 · fro-bot/agent
Long-lived opencode serve grows with every repo it serves; recycle it when idle #1923DescriptionThe workspace runs one long-lived opencode serve for every repo under /workspace/repos. Its memory grows with each repo it serves and is never released. On a small host this eventually takes the host down, or, with a container memory limit, gets OpenCode OOM-killed in the middle of a run.
Evidence
The gateway runs at v0.124.1 on a 2 GB droplet with no swap.
- Incident. After about 2.7 days of uptime,
opencode serve held about 1.1 GiB RSS. One Reply with only the word OK. launch on marcusrbrown/systematic then exhausted host memory. /operator/health stopped answering for about 12 minutes until I restarted the workspace.
- Measurement. I then capped the workspace at 896 MiB and sampled cgroup memory for 45 minutes. Across three launches on three different repos (
marcusrbrown/infra, fro-bot/agent, marcusrbrown/systematic), anonymous memory went from about 360 MiB to about 618 MiB and stayed there. Almost all of it belonged to the opencode serve process, with node (workspace-agent) at about 64 MiB.
Upstream, anomalyco/opencode#47727 describes the same pattern, where per-directory instances are never disposed. It was closed without a confirmed fix, and the instance-cache bound proposed in anomalyco/opencode#48638 was reverted. anomalyco/opencode#51003 is still open for a related per-directory leak.
There is also an unconfirmed contributor: marcusrbrown/systematic is itself an OpenCode plugin repo, and its opencode.json loads ./src/index.ts next to the Systematic plugin baked into the image.
What I'd like
Have the supervisor in apps/workspace-agent/src/opencode-server.ts recycle opencode serve when no run is active. A few possible triggers, any of which would do:
- after an idle period;
- once its RSS passes a threshold while idle;
- after N distinct directories.
Today the only recycle is a crash or a manual restart. A planned restart between runs would keep the process from growing for days, so an OOM kill wouldn't land in the middle of someone's run. Activitymarcusrbrown commented on Nov 5, 2026 CollaboratorAuthor More actions Fixed by #2076. OpenCode V2 releases a location's memory when it goes idle, so the workspace's managed config now sets experimental.location_idle_timeout to 10 minutes. A 24-hour production sample is still running to confirm the numbers under real traffic. marcusrbrown commented on Nov 6, 2026 CollaboratorAuthor More actions @fro-bot I sampled opencode serve in the infra gateway workspace every 5 minutes for 24 hours, from 2026-11-05T03:45Z to 2026-11-06T03:45Z, for 288 samples. The workspace ran fro-bot/agent v0.135.0, then v0.135.1 from 03:00Z, on OpenCode V2 2.2.5, with a 1 GiB container limit.
| Process |
Window |
RSS start → end |
RSS max |
Trend |
| Long-lived (about 8 h old when sampling began) |
21.6 h |
153 → 161 MiB |
165 MiB |
about +0.4 MiB/h |
| After the 01:21Z recreate (config change) |
1.5 h |
262 → 232 MiB |
291 MiB (01:30Z, during 3 short runs) |
falling |
| After the 03:00Z recreate (v0.135.1 deploy) |
0.75 h |
269 → 260 MiB |
269 MiB |
flat to falling |
- Every sample showed exactly one
opencode serve process, and the supervisor logged no respawns.
- Over the long-lived window the container's cgroup usage fell from 447 to 233 MiB. Page cache was reclaimed (file 73 → 30 MiB) while anon memory held at about 175 MiB.
- Host available memory never dropped below 757 MB.
- A freshly spawned process starts around 260–290 MiB. The long-lived process sat at 153–165 MiB.
Caveats:
- Traffic was light. The long-lived window had no dashboard runs on marcusrbrown/infra, and I did not count Discord-initiated runs. So the flat line reflects a mostly idle workload. It does not show the per-repo growth reported here.
- The cgroup lines went stale after the first recreate because the sampler kept reading the old container. The RSS figures after each recreate come from the new process.
- A 5-minute interval misses short peaks.
On this sample, V2 shows no idle growth. Reproducing the original report still needs a busy window that touches several repos. fro-bot commented on Nov 6, 2026 Thanks—this supports idle stability on V2, not yet resolution of the original multi-repo growth. The uninterrupted 21.6-hour window is the strongest evidence: RSS stayed at 153–165 MiB without supervisor respawns. The recreated processes should remain separate observations, and the stale cgroup readings should not be used after recreation.
Keeping this closed after #2076 seems reasonable, with busy-workload validation still outstanding. For that follow-up:
- Exercise several distinct repos repeatedly, counting both dashboard and Discord runs.
- After each batch, leave locations idle beyond the configured 10-minute timeout and compare settled RSS across batches—not just against startup RSS.
- Track process identity and refresh the container/cgroup target after every recreate; sample more frequently during runs to capture peaks.
The key signal is whether post-idle memory keeps stair-stepping upward across batches. If it does, reopen this with that trace; this sample alone does not justify adding supervisor recycling.
Run Summary
| Field |
Value |
| Event |
issue_comment |
| Repository |
fro-bot/agent |
| Run ID |
42161727141 |
| Cache |
hit |
| Session |
ses_e50eaeb1fffe85iWi7FP3lkjsk |
MetadataMetadataStatusShow more project fields
DevelopmentNo branches or pull requestsIssue actions
|