GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Bug]: sustained high CPU and memory growth in long-running web sessions with large SQLite history · Issue #46341 · anomalyco/opencode

[Bug]: sustained high CPU and memory growth in long-running web sessions with large SQLite history #46341

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
[Bug]: sustained high CPU and memory growth in long-running web sessions with large SQLite history#46341
Copy link
Assignees
nexxeln

Description

@Samyak2406
Samyak2406
opened on Aug 31, 2026
Issue body actions

Description

A long-running opencode web process can sustain very high CPU and memory usage while an agent session is active. The behavior appears to worsen as session history and SQLite event data grow.

This is not only a UI rendering issue. The backend appears to repeatedly process and persist large session/event data during agent iterations.

Observed behavior

  • OpenCode version: 1.18.15
  • Command: opencode web
  • Process lifetime: more than 2 days
  • CPU usage: approximately 180–210% sustained
  • RSS: approximately 1.5–1.7 GB
  • Physical memory footprint: tens of GB
  • SQLite database: approximately 66–71 GB
  • The process was actively running an agent loop involving tool calls and other background work.

After stopping the process and inspecting the database:

  • The event table occupied approximately 39.7 GB.
  • Approximately 2,142 event rows were associated with one aggregate.
  • Deleting sessions did not remove all associated event rows.
  • Orphaned event rows remained because event records were not fully tied to session deletion.
  • After removing orphaned events and vacuuming the database, the database reduced to approximately 248 KB.

Expected behavior

Opening or continuing a session should load only:

  • Session metadata.
  • The visible/recent message window.
  • A bounded summary/context window.

Older messages, tool outputs, attachments, and event history should be loaded lazily only when explicitly requested.

CPU and memory usage should remain bounded as session history grows. Large historical data should not be repeatedly hydrated or serialized during every agent iteration.

Suspected causes

These are hypotheses requiring profiling:

  1. Full or oversized session history is hydrated during prompt-loop iterations or compaction.
  2. Large tool outputs and serialized event payloads are retained inline in SQLite.
  3. Event records are written at high frequency during tool execution.
  4. Session deletion does not transactionally remove all related event records.
  5. Large SQLite pages/cache/mmap activity amplifies memory pressure and serialization cost.

Suggested fixes

  • Hydrate only the recent/required context for prompt execution.
  • Lazy-load historical messages and collapsed tool output.
  • Bound tool-output and event-payload sizes.
  • Store large historical output externally or in compressed cold storage.
  • Add transactional session/event deletion with orphan-event cleanup.
  • Prevent deletion of active sessions.
  • Add storage quotas and backpressure.
  • Add profiling/telemetry for prompt hydration, event serialization, SQLite writes, and cache usage.
  • Add a long-running soak test covering large tool output, compaction, child sessions, reconnects, and pruning.

Related issues

  • opencode process consumes 185% avg CPU / 500MB+ RAM constantly #31831
  • [FEATURE]: Session Lifecycle Management — unified storage reclamation, auto-archival, and child session cleanup #16101
  • perf(core): avoid hydrating discarded compacted session parts #35570

Activity

  1. github-actions
    assigned
    nexxeln
    on Aug 31, 2026
  2. github-actions commented on Aug 31, 2026

    @github-actions
    github-actionsBot
    on Aug 31, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue appears to overlap significantly with existing issues. Please check:

    • bug: Snapshot.diffFull serialises full patch text into message rows, causing unbounded DB growth and web UI hang #46138: Same author, same environment, same symptoms — 66–71 GB SQLite DB, sustained high CPU on opencode web, orphaned event rows, Snapshot.diffFull pipeline writing unbounded data to message rows. This issue appears to be a broader framing of the same root cause already reported in bug: Snapshot.diffFull serialises full patch text into message rows, causing unbounded DB growth and web UI hang #46138.
    • 80MB/s persisted disk scan #46256: High sustained disk I/O from opencode during long-running sessions.
    • Web UI retains 40 full session transcripts #46119: Web UI retains large amounts of session transcript data in memory, contributing to memory growth.

    If this is intentionally a separate, higher-level tracking issue covering multiple root causes (DB growth, memory, lazy loading, orphan cleanup), please clarify that relationship to #46138 so maintainers can link them appropriately.

  3. CryptArchy commented on Sep 2, 2026

    @CryptArchy
    CryptArchy
    on Sep 2, 2026
    More actions

    A data point on hypothesis 4, from a headless opencode serve on 1.18.23 that deletes every session programmatically after its run.

    We see the same orphans you do — 509 of 2,065 aggregates in event_sequence had no matching session row: 127,081 events, 239 MB, in a 1.6 GB database.

    But the delete path itself works. Creating a session over the API and deleting it with DELETE /session/:id removes its event and event_sequence rows along with the session:

    session_rows_after=0   events_after=0   seq_rows_after=0
    

    So it isn't a missing cleanup path, it's one that doesn't always complete. #30814 notes that code swallows its exceptions, and #42538 reports deletes taking 10–30s and leaving ghost state; our deletes run on a deadline, which would race exactly that. There's also no database-level backstop: event.aggregate_id references event_sequence(aggregate_id), not session(id), so nothing cascades when the application path fails.

    Byte breakdown from the same database, via dbstat — event is 1,035 MB of the 1.6 GB, against part 442 MB and message 13 MB. By type:

    type rows MB
    message.part.updated.1 299,792 833
    message.updated.1 114,787 59
    session.updated.1 33,795 20

    Lastly, in case it helps anyone considering a prune: we deleted every event row from a .backup copy and served it. The session list and session load were identical to a pristine copy of the same database — 76 sessions listed either way, and the same session returned 192 messages / 883 parts / 27 text parts. 1.59 GB → 467 MB after vacuum, with session, message and part untouched. On 1.18.23 only; that's an observation, not a guarantee about other versions.

  4. thdxr commented on Oct 11, 2026

    @thdxr
    thdxr
    on Oct 11, 2026
    Member
    More actions

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

  5. thdxr
    closed this as not plannedon Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @nexxeln
    nexxeln

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.