You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
opencode process consumes 185% avg CPU / 500MB+ RAM constantly #31831
Corroborating report on the latest version (v1.17.13). Same symptom — high CPU while idle (no active conversation) — with thread-level data that may help narrow it down.
Environment
macOS 26.4.1 (build 25E253), Apple Silicon
16 cores / 128 GB RAM
opencode v1.17.13 (latest release)
Two opencode processes running against a large TS monorepo (cwd = repo root)
Measurements (idle, no active prompt)
Two processes, both top-2 CPU consumers on the whole machine (above WindowServer):
PID
invocation
%CPU
RSS
accumulated CPU time
15573
opencode (TUI)
~200%
~1.86 GB
80+ min
77486
opencode -s ses_… (serve)
~100%
~1.10 GB
177+ min
5 samples at 3s intervals — the load is sustained, not a spike, and RSS is flat (this is a CPU busy-loop, not a memory leak):
One thread is pinned at exactly 100.0% in state R (runnable/spinning) with ~31 min of UTIME on that single thread. A handful of others show elevated cumulative UTIME (~1:27 each); the rest are idle:
%CPU STAT STIME UTIME
100.0 R 2:36.53 31:16.74 <-- hot spinning thread
0.0 S 0:06.12 1:27.09
0.0 S 0:06.05 1:27.06
0.0 S 0:06.48 1:24.11
0.0 S 0:04.03 1:32.69
... (remaining threads idle)
Thread names (from sample)
The process has ~57 threads. Named worker pools present: Bun Pool 0..7, Heap Helper Thread x3, JavaScriptCore libpas scavenger, an HTTP Client, and notably fff-bg-0..3 (background file-finder / watcher workers). Given the spinning thread + a large monorepo as cwd, a file-watch / indexing busy-loop seems a plausible culprit.
Sample stack (main thread)
The binary ships stripped (symbols show as ???), so the deep frames aren't resolvable, but the main thread is parked in kevent64 as expected — the CPU is being burned on the separate R thread above:
Call graph:
Thread DispatchQueue_1: com.apple.main-thread (serial)
start (in dyld)
??? (in opencode) +0x9bdd0c
... +0x9be670 / +0x9c7138 / +0x3c14e0 / +0x117f3d0 / +0xe735ec / +0xe78b2c / +0x599a98
kevent64 (in libsystem_kernel.dylib)
Happy to run a targeted trace (e.g. sample on the specific R thread TID, fs_usage, or dtruss for the busy loop's syscalls) if a maintainer can point me at what would be most useful. If a debug/unstripped build is available I can get resolved frames for the hot thread.
Additional reproduction on opencode 1.18.3. This was a transient stuck state: restarting opencode immediately returned CPU usage to normal, and it has not reproduced yet.
Environment
macOS 26.5.1, Apple Silicon
opencode 1.18.3 TUI
Started at a repository root with roughly 6.5k files
All LSPs were disabled
MCP child processes were idle at 0% CPU
Observed behavior
The opencode process remained at approximately 99–100% CPU after the active work had ended.
Repeated top samples showed 77.5% and then 100.2% two seconds apart; ps also reported about 99%.
A five-second /usr/bin/sample capture reported a 6.6 GB physical footprint. ps reported roughly 1.18 GB RSS. The process had 33 threads.
The main thread was parked in kevent64 for essentially the entire sample. The HTTP client, Bun pools, heap helper threads, FFF background threads, and file-watcher threads were also waiting/sleeping.
One separate thread named Worker remained inside JIT/unknown code for all 3772/3772 samples, consistent with a single-thread busy loop. The release binary is stripped, so the JavaScript frames could not be resolved.
The log showed a long agent run reaching 56 steps and exiting normally. Two later requests logged:
error=Aborted stack=undefined
A subsequent run also exited normally, but the process was still pinned near 100% CPU a couple of minutes later. Restarting opencode cleared both the high CPU condition and the inflated memory footprint.
There is no deterministic reproduction yet. The evidence appears consistent with a Worker lifecycle/cleanup issue after a long session and aborted requests, but that is only a hypothesis; the native FFF threads themselves were asleep during this sample.
Local paths, project name, provider/model information, process/session/run/message IDs, and timestamps have been omitted. A full sample capture was retained and can be sanitized further if maintainers need it.
Activity
github-actions commentedon Jun 11, 2026
This issue might be a duplicate of existing issues. Please check:
If your issue is specifically about memory growth, please follow the instructions in #20695 (heap snapshot upload) to help the team diagnose it.
thaoula commentedon Jul 3, 2026
Corroborating report on the latest version (v1.17.13). Same symptom — high CPU while idle (no active conversation) — with thread-level data that may help narrow it down.
Environment
Measurements (idle, no active prompt)
Two processes, both top-2 CPU consumers on the whole machine (above WindowServer):
opencode(TUI)opencode -s ses_…(serve)5 samples at 3s intervals — the load is sustained, not a spike, and RSS is flat (this is a CPU busy-loop, not a memory leak):
Per-thread breakdown (
ps -M 15573)One thread is pinned at exactly 100.0% in state
R(runnable/spinning) with ~31 min of UTIME on that single thread. A handful of others show elevated cumulative UTIME (~1:27 each); the rest are idle:Thread names (from
sample)The process has ~57 threads. Named worker pools present:
Bun Pool 0..7,Heap Helper Threadx3,JavaScriptCore libpas scavenger, anHTTP Client, and notablyfff-bg-0..3(background file-finder / watcher workers). Given the spinning thread + a large monorepo as cwd, a file-watch / indexing busy-loop seems a plausible culprit.Sample stack (main thread)
The binary ships stripped (symbols show as
???), so the deep frames aren't resolvable, but the main thread is parked inkevent64as expected — the CPU is being burned on the separateRthread above:Happy to run a targeted trace (e.g.
sampleon the specificRthread TID,fs_usage, ordtrussfor the busy loop's syscalls) if a maintainer can point me at what would be most useful. If a debug/unstripped build is available I can get resolved frames for the hot thread.thaoula commentedon Jul 6, 2026
Hey Team / @thdxr,
Is there anything we can do to provide more information to help track this issue?
OpenCode is frequently smashing the CPU and I have to close it when not in use.
Regards,
Tarek
arichyx commentedon Jul 18, 2026
Additional reproduction on opencode 1.18.3. This was a transient stuck state: restarting opencode immediately returned CPU usage to normal, and it has not reproduced yet.
Environment
Observed behavior
topsamples showed 77.5% and then 100.2% two seconds apart;psalso reported about 99%./usr/bin/samplecapture reported a 6.6 GB physical footprint.psreported roughly 1.18 GB RSS. The process had 33 threads.kevent64for essentially the entire sample. The HTTP client, Bun pools, heap helper threads, FFF background threads, and file-watcher threads were also waiting/sleeping.Workerremained inside JIT/unknown code for all 3772/3772 samples, consistent with a single-thread busy loop. The release binary is stripped, so the JavaScript frames could not be resolved.Abridged hot-thread stack from the 1.18.3 binary:
Preceding session state
The log showed a long agent run reaching 56 steps and exiting normally. Two later requests logged:
A subsequent run also exited normally, but the process was still pinned near 100% CPU a couple of minutes later. Restarting opencode cleared both the high CPU condition and the inflated memory footprint.
There is no deterministic reproduction yet. The evidence appears consistent with a Worker lifecycle/cleanup issue after a long session and aborted requests, but that is only a hypothesis; the native FFF threads themselves were asleep during this sample.
Local paths, project name, provider/model information, process/session/run/message IDs, and timestamps have been omitted. A full
samplecapture was retained and can be sanitized further if maintainers need it.fix(shell): throttle streaming output metadata updates to cut CPU
fix(shell): throttle streaming output metadata updates to cut CPU
fix(tui): reduce per-frame allocation and re-parse while streaming
github-actions commentedon Sep 18, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.