Skip to content

tui: RSS grows unbounded around ~300k-token sessions, OOM-killed at ~30 GB (v2.0.18, Linux) #51620

Closed

Description

@davidvazteixeira

Summary

Sessions that reach roughly 300k tokens blow up in memory: the opencode 2.x
process grows to tens of GB and gets OOM-killed. Today the kernel killed it at
~29.7 GB anon RSS (43.7 GB virtual) on a 31 GB machine. This does not seem
tied to wall-clock session length — it correlates with the session reaching
~300k tokens (many tool calls and large tool outputs). The same workflow on
1.18.x was fine; this started after updating to 2.x (currently v2.0.18).

Environment

  • opencode version: v2.0.18 (single native ELF binary, ~/.opencode/bin/opencode, 203 MB)
  • OS: Linux 6.8.0-142-generic x86_64
  • Terminal: TERM=xterm-256color, COLORTERM=truecolor
  • Shell: /bin/bash
  • Install/channel: latest (opencode --version -> v2.0.18)
  • Active plugins: one local plugin (~/.config/opencode/plugins/rtk.ts, command rewriter); MCP servers enabled: playwright (local stdio) and huggingface (remote URL)

Reproduction

  1. Work inside a single session until it accumulates roughly 300k tokens (many bash tool calls, large tool outputs, file reads/edits).
  2. RSS grows from a few hundred MB into tens of GB as the session approaches that size.
  3. The system starts swapping/hangs and the kernel OOM killer kills opencode.

Observed 3 times in one day; the earlier two ended in a full system freeze
(power cycle). It is not a "left it running for hours" issue: it reproduces
with active work in one growing session, around the ~300k token mark.

Expected Behavior

RSS stays bounded (or grows only modestly) as the session history grows; no
OOM kill.

Actual Behavior

Kernel log from the crash (host/user redacted):

kernel: xfce4-clipman invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0
kernel: oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/session-3.scope,task=opencode,pid=2290047,uid=1000
kernel: Out of memory: Killed process 2290047 (opencode) total-vm:43678496kB, anon-rss:29699100kB, file-rss:3516kB, shmem-rss:0kB, UID:1000 pgtables:60808kB oom_score_adj:0
kernel: oom_reaper: reaped process 2290047 (opencode), now anon-rss:488kB, file-rss:852kB, shmem-rss:0kB
  • ~30 GB anon RSS in the single opencode process (the RSS holder was opencode itself, not its children).
  • ~/.local/share/opencode/log/opencode.log was 14.8 MB / ~74k lines, mostly INFO (permission evaluations, loop/stream lines). No memory-related error was logged before the kill.
  • No heap snapshot is available (the process was OOM-killed). Previous boots show no OOM entries.

Additional Context

Activity

  1. github-actions commented on Sep 27, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • #51497: v2 repeatedly reloads and decodes the full session history on each LLM call, potentially driving memory growth in long sessions.
    • #41502: v2 RSS grows rapidly during an active agent turn and eventually causes an OOM crash.
  2. VariableVince commented on Oct 11, 2026

    @VariableVince

    @davidvazteixeira Was this solved for you since v2.0.21? From #51761 it looks like it hopefully should be

  3. davidvazteixeira commented on Oct 11, 2026

    @davidvazteixeira
    Author

    8. @davidvazteixeira Was this solved for you since v2.0.21? From #51761 it looks like it hopefully should be

    Although memory consumption has remained much higher since version 2.x, I haven't experienced any memory spikes over the past week.

  4. neriousy commented on Oct 19, 2026

    @neriousy
    Member

    Thanks for the follow-up confirming that the memory spikes stopped. Closing this report of runaway memory growth and OOM as resolved based on that update—not as a claim that v2's higher baseline memory usage is resolved. If the spikes or OOM return on the latest v2 release, please open a new report with reproduction details and link back here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions