opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix: add LRU eviction to LSP client file and diagnostics tracking

Open hendem opened this issue 1 week ago • 2 comments

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.

hendem avatar Jan 06 '26 06:01 hendem