Memory leak: compacted tool outputs and attachments not cleared from storage #4481

Closed
opened 2026-02-16 17:44:19 -05:00 by yindo · 2 comments
Owner

Originally created by @hendem on GitHub (Jan 8, 2026).

Originally assigned to: @rekram1-node on GitHub.

Problem

When compaction prunes old tool outputs (in packages/opencode/src/session/compaction.ts), only the time.compacted timestamp is being set. The actual output string (often containing large file contents) and attachments array (base64 images/PDFs from the Read tool) remain in the storage JSON files indefinitely.

This causes storage files to grow unbounded, contributing to memory issues during extended use.

Expected Behavior

When prune() marks tool parts as compacted, it should also clear the output string and attachments array to free memory.

Actual Behavior

Only time.compacted is set; large output strings and attachment data persist indefinitely.

Related Issues

  • #4315 - Memory stays unbounded: ACP session map + compacted tool outputs
  • #5363 - opencode eating 70gb of memory?
  • #7046 - memory leak
Originally created by @hendem on GitHub (Jan 8, 2026). Originally assigned to: @rekram1-node on GitHub. ## Problem When compaction prunes old tool outputs (in `packages/opencode/src/session/compaction.ts`), only the `time.compacted` timestamp is being set. The actual `output` string (often containing large file contents) and `attachments` array (base64 images/PDFs from the Read tool) remain in the storage JSON files indefinitely. This causes storage files to grow unbounded, contributing to memory issues during extended use. ## Expected Behavior When `prune()` marks tool parts as compacted, it should also clear the `output` string and `attachments` array to free memory. ## Actual Behavior Only `time.compacted` is set; large output strings and attachment data persist indefinitely. ## Related Issues - #4315 - Memory stays unbounded: ACP session map + compacted tool outputs - #5363 - opencode eating 70gb of memory? - #7046 - memory leak
yindo added the perf label 2026-02-16 17:44:19 -05:00
yindo closed this issue 2026-02-16 17:44:19 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 8, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #4315: Memory stays unbounded: ACP session map + compacted tool outputs
  • #5363: opencode eating 70gb of memory?
  • #7046: memory leak
  • #6172: High CPU usage (100%+) during LLM streaming in long sessions due to O(n) text buffer rendering
  • #6213: Memory leak during prolonged usage

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 8, 2026): This issue might be a duplicate of existing issues. Please check: - #4315: Memory stays unbounded: ACP session map + compacted tool outputs - #5363: opencode eating 70gb of memory? - #7046: memory leak - #6172: High CPU usage (100%+) during LLM streaming in long sessions due to O(n) text buffer rendering - #6213: Memory leak during prolonged usage Feel free to ignore if none of these address your specific case.
Author
Owner

@hendem commented on GitHub (Jan 8, 2026):

Closing as duplicate - using existing issue #4315 instead.

@hendem commented on GitHub (Jan 8, 2026): Closing as duplicate - using existing issue #4315 instead.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4481