GeezerVison is showing github.com — Memory leak: TUI and Slack bot event listeners not cleaned up · Issue #9155 · anomalyco/opencode
Memory leak: TUI and Slack bot event listeners not cleaned up #9155
Labels
perfIndicates a performance issue or need for optimization Description
Problem
Several event listeners in the TUI and Slack bot are never cleaned up:
TUI Sync Context (sync.tsx)
The sdk.event.listen() call returns an unsubscribe function that is never called:
// Listener never cleaned up
sdk.event.listen((e) => { ... })
Tooltip Component (tooltip.tsx)
Mouse event listeners (mouseenter, mouseleave) are added to elements but never removed on component unmount, causing accumulation.
Slack Bot (slack/index.ts)
- Sessions Map grows unbounded (no cleanup of old sessions)
- No graceful shutdown handling (SIGINT/SIGTERM)
- No limit on maximum concurrent sessions
Impact
- Event listeners accumulate over component lifecycles
- Sessions accumulate in Slack bot
- Memory grows continuously in long-running processes
Relates to #5363
Expected Behavior
- TUI event listeners should be unsubscribed in
onCleanup
- Tooltip should remove event listeners on unmount
- Slack bot should clean up old sessions and handle shutdown
Activity
github-actions commented on Jan 17, 2026
This issue appears to be part of a broader set of memory leak issues across the codebase. Please check these related issues for context:
While this issue specifically addresses TUI sync context, tooltip components, and Slack bot sessions, the underlying patterns (missing cleanup, unsubscribe functions ignored, unbounded collections) are consistent across these related issues. Consider coordinating fixes across all these issues to establish consistent cleanup patterns throughout the codebase.
sauerdaniel commented on Feb 16, 2026
ContributorAuthor
More actions
Status: fix is implemented in PR #9147. Remaining blocker is CI on e2e (windows) (NotFoundError), which cascades to the linux gate.
thdxr commented on Apr 2, 2026
Closing in favor of #20695 where we're collecting all memory-related problems. Please follow that issue for updates.
Metadata
Metadata
perfIndicates a performance issue or need for optimization Development
No branches or pull requestsIssue actions