Skip to content

Memory leak during long-running session with multiple bash tool calls #33385

Description

@lildengzi

Description

envirment:
tools value

Node v26.1.0
Shell fish, inside kitty terminal
RAM 14GB + 14GB swap
CPU AMD Ryzen 7 6800H
description:
During a ~2 hour interactive session involving many consecutive bash tool invocations (setting up a macOS KVM), the opencode process RSS grew monotonically from ~300MB to a peak of 8.6GB (reported by systemd for the parent kitty scope, opencode as dominant child).
The bash subprocess group alone peaked at 468MB, and open_code.db grew to ~70MB. No OOM kill occurred only due to 14GB swap + CachyOS aggressive reclaim. Meanwhile a QEMU VM consuming 4.9GB RSS was also running on the same host, making total pressure ~13.5GB.
No explicit errors in ~/.local/share/opencode/log/opencode.log (1.8MB, 10093 lines).

influence:
Near-OOM on a 14GB host with swap thrashing. Lighter hosts would trigger OOM kill.
guess:
Buffered bash tool output or tool-call history not released between invocations.

Plugins

No response

OpenCode version

1.17.8

Steps to reproduce

  1. Start a long session with heavy tool-call throughput (e.g. quickemu macOS setup)
  2. Make many consecutive bash calls over ~2 hours
  3. Monitor with ps aux --sort=-%mem — RSS grows monotonically

Screenshot and/or share link

No response

Operating System

OS CachyOS (Arch Linux), kernel 7.0.12 LTO

Terminal

kitty

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions