Skip to content

Memory leak: Multiple opencode processes accumulate over days and don't terminate on session exit #14199

Closed

Description

@davidvv

When using opencode interactively, multiple opencode processes accumulate over time and don't terminate properly when sessions end. This leads to multiple processes running simultaneously (5+ observed), each consuming 300-1000MB, with processes dating back 3-5 days. Total memory consumption reached 3.35GB across 5 processes, contributing to system freeze on Ubuntu server (94.44% RAM used, OOM crash).

Steps to reproduce:

  1. Start opencode session
  2. Use it for some time
  3. Exit session normally
  4. Start new session in different project
  5. Repeat over several days
  6. Check: ps aux | grep opencode

Actual: Multiple opencode processes remain after sessions end (PID examples from 3-5 days old)

Expected: Process should terminate on session exit, releasing memory and file descriptors.

Environment: opencode 1.2.x on macOS and Linux (arm64/x86_64)

Root cause: Background processes not killed on session exit, event listeners not cleaned up, improper signal handling.

Related issues: #13477, #13796, #13778, #13777

Proposed fixes: Proper session tracking and child process termination on exit, auto-cleanup of stale processes (>24h), improved process lifecycle in opencode serve, --cleanup flag.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    perfIndicates a performance issue or need for optimization
    on Feb 18, 2026
  2. thdxr commented on Apr 2, 2026

    @thdxr
    Member

    Closing in favor of #20695 where we're collecting all memory-related problems. Please follow that issue for updates.

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)perfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions