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 — fix: add LRU eviction to LSP client file and diagnostics tracking by hendem · Pull Request #7050 · anomalyco/opencode

Conversation

@hendem

@hendem hendem commented Jan 6, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Fixes #3013

Summary

  • Add LRU eviction to LSP client file and diagnostics tracking maps
  • Create reusable LRUMap utility class with configurable max size

Problem

The LSP client tracks files and diagnostics in unbounded Maps. In large codebases or long sessions, these maps grow without limit, contributing to memory pressure.

Solution

Replace plain Map with LRUMap that automatically evicts least-recently-used entries when a maximum size is exceeded. Default limits:

  • Files: 1000 entries
  • Diagnostics: 500 entries

Testing

Added tests for LRUMap utility. LSP functionality preserved.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI review requested due to automatic review settings January 6, 2026 06:02
Copilot started reviewing on behalf of hendem January 6, 2026 06:02
View session
@github-actions

github-actions Bot commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI reviewed Jan 6, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses memory leaks in the LSP client by implementing LRU (Least Recently Used) eviction for file and diagnostics tracking. It introduces a reusable LRUMap utility class and applies it to prevent unbounded memory growth during extended LSP sessions.

Key Changes:

  • Created a generic LRUMap<K, V> class with automatic eviction when capacity is exceeded
  • Applied LRU eviction to both files and diagnostics tracking with a limit of 1000 entries per LSP client
  • Added comprehensive test coverage for the LRUMap implementation

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
packages/opencode/src/util/lru-map.ts New LRUMap utility class implementing LRU eviction policy using JavaScript Map's insertion order guarantee
packages/opencode/test/util/lru-map.test.ts Comprehensive test suite with 10 test cases covering basic operations, eviction behavior, and edge cases
packages/opencode/src/lsp/client.ts Migrated files object and diagnostics Map to use LRUMap with MAX_TRACKED_FILES capacity

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/opencode/src/util/lru-map.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/util/lru-map.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/util/lru-map.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/util/lru-map.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hendem hendem mentioned this pull request Jan 7, 2026
fix: clean up pending permissions when session is deleted #7154
Closed
@hendem
hendem requested a review from Copilot January 7, 2026 04:31
Copilot started reviewing on behalf of hendem January 7, 2026 04:32
View session
Copilot AI reviewed Jan 7, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/opencode/src/util/lru-map.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/util/lru-map.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hendem
hendem requested a review from Copilot January 7, 2026 04:44
Copilot started reviewing on behalf of hendem January 7, 2026 04:44
View session
Copilot AI reviewed Jan 7, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/opencode/src/lsp/client.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/lsp/client.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hendem
hendem requested a review from Copilot January 7, 2026 04:52
Copilot started reviewing on behalf of hendem January 7, 2026 04:53
View session
Copilot AI reviewed Jan 7, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/opencode/src/util/lru-map.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hendem
hendem requested a review from Copilot January 7, 2026 04:59
Copilot started reviewing on behalf of hendem January 7, 2026 04:59
View session
Copilot AI reviewed Jan 7, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added the needs:issue label Jan 9, 2026
@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:issue label Jan 9, 2026
@hendem hendem mentioned this pull request Jan 9, 2026
fix: force kill MCP server processes on dispose to prevent orphan processes #7424
Closed
@github-actions github-actions Bot added needs:issue and removed needs:issue labels Jan 9, 2026
@fwang
fwang force-pushed the dev branch from 4da2998 to a618fbe Compare January 9, 2026 06:32
@fwang
fwang requested a review from adamdotdevin as a code owner January 9, 2026 06:32
Mark Henderson and others added 5 commits January 10, 2026 14:13
Mark Henderson @fwang
fix: add LRU eviction to LSP client file and diagnostics tracking
c7d55cc
The LSP client's files object and diagnostics Map grew unbounded as
files were opened during a session. Every unique file path got an
entry that was never removed, causing memory to accumulate.

Changes:
- Add LRUMap utility class with configurable capacity
- Use LRUMap for both files and diagnostics tracking in LSP client
- Set MAX_TRACKED_FILES to 1000 per client
- Add comprehensive tests for LRUMap behavior

When capacity is exceeded, least recently used entries are evicted.
This bounds memory usage while keeping recently accessed files tracked.
Mark Henderson @fwang
address PR review comments: fix get() for falsy values, add capacity …
3d53697
…validation, add tests
Mark Henderson @fwang
fix: remove undefined check and add documentation for LRU behavior
7154eeb
@fwang
wip: zen
74d8ca9
Revert "wip: zen"

This reverts commit a8844ee9a473d14a36b352d76b9b894745dce565.
Mark Henderson @fwang
refactor: change while loop to if statement for LRU eviction
1fcd656
@fwang
fwang force-pushed the fix/lsp-client-file-tracking-leak branch from 6ff29c1 to 1fcd656 Compare January 10, 2026 19:13
@hendem
Merge branch 'dev' into fix/lsp-client-file-tracking-leak
927bde4
@github-actions github-actions Bot mentioned this pull request Jan 17, 2026
fix(lsp): Clear diagnostics and files maps on client shutdown #9144
Closed
3 tasks done
@thdxr
thdxr force-pushed the dev branch from cbab81f to 2d3c7a0 Compare January 30, 2026 04:50
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 00637c0 to 71e0ba2 Compare January 30, 2026 14:32
@thdxr
thdxr force-pushed the dev branch 3 times, most recently from f1ae801 to 08fa7f7 Compare January 30, 2026 14:37
@github-actions github-actions Bot mentioned this pull request Feb 4, 2026
fix(memory): resolve 6 memory leak issues in long-running sessions #12053
Closed
@github-actions github-actions Bot mentioned this pull request Feb 28, 2026
fix: consolidate memory leak fixes from #14650 and #8953 #15435
Closed
3 of 6 tasks
@github-actions github-actions Bot mentioned this pull request Mar 9, 2026
fix: resolve multiple memory leaks causing unbounded growth #16695
Closed
3 of 6 tasks
@github-actions

github-actions Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@adamdotdevin adamdotdevin Awaiting requested review from adamdotdevin

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uses a huge amount of memory

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@hendem @fwang
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.