Description
A long-running OpenCode server instance (2+ days) consumes 1.76 GB (602 MB RSS + 1.15 GB swap) on an 8 GB system. The SQLite database grows to 1.99 GB with no automatic cleanup — 1,706 sessions spanning 53 days, 274K parts (1.49 GB) never pruned.
Root causes identified:
- No data retention — sessions are only soft-archived, never deleted
- auto_vacuum = OFF — deleted data never reclaims disk space
- No periodic WAL checkpoint — WAL file grows unbounded during long sessions
- Compaction marks parts but keeps full data — dead weight in SQLite
- Bash tool output accumulates unboundedly — verbose commands can grow to hundreds of MB in the output string
- Edit tool Levenshtein uses O(n×m) matrix — can spike to ~400 MB for 10K char strings
- FileTime per-session tracking never pruned — slow memory leak over instance lifetime
- RPC pending map has no timeout — orphaned promises leak if workers die
- LSP diagnostics Map grows monotonically — empty entries never deleted
Measured metrics:
| Metric | Value |
|---|
| Main process RSS | 602 MB |
| Main process swap | 1.15 GB |
| Peak RSS (VmHWM) | 1.64 GB |
| SQLite DB size | 1.99 GB |
| DB parts table | 1.49 GB |
| Sessions | 1,706 (never auto-deleted) |
| auto_vacuum | OFF |
Plugins
No plugins
OpenCode version
0.1.44 (dev build)
Steps to reproduce
- Run
opencode serve on a machine with 8 GB RAM - Use it actively for 2+ days with multiple worktrees
- Monitor RSS with
ps aux or /proc/<pid>/status — memory grows monotonically - Check
opencode.db file size — grows without bound since archived sessions are never deleted
Screenshot and/or share link
N/A
Operating System
Ubuntu 22.04 (Linux x86_64, 8 GB RAM, 16 GB swap)
Terminal
N/A (headless server mode via opencode serve)
Description
A long-running OpenCode server instance (2+ days) consumes 1.76 GB (602 MB RSS + 1.15 GB swap) on an 8 GB system. The SQLite database grows to 1.99 GB with no automatic cleanup — 1,706 sessions spanning 53 days, 274K parts (1.49 GB) never pruned.
Root causes identified:
Measured metrics:
Plugins
No plugins
OpenCode version
0.1.44 (dev build)
Steps to reproduce
opencode serveon a machine with 8 GB RAMps auxor/proc/<pid>/status— memory grows monotonicallyopencode.dbfile size — grows without bound since archived sessions are never deletedScreenshot and/or share link
N/A
Operating System
Ubuntu 22.04 (Linux x86_64, 8 GB RAM, 16 GB swap)
Terminal
N/A (headless server mode via
opencode serve)