Skip to content

补齐内存泄漏 cap: LSP open-docs 50 上限 + fileReadCache 16MB 字节上限 (对齐 CC 2.1.208) #75

Closed

Description

@dahai80

背景

对齐 Claude Code 2.1.208 内存泄漏 cap 特性 (fusion-code-enhance-0819.md Tier-1 #7)。
CC 2.1.208 为长会话加 3 处内存 cap: LSP LRU 50 文档 / MCP stderr 64MB / 文件编辑读缓存 16MB。

审计结果 (对照 main 实际)

子项 状态
MCP stderr 64MB ✅ 已落地 — src/services/mcp/client.ts:1009 if (stderrOutput.length < 64 * 1024 * 1024)
LSP open-docs 50 上限 ⬜ 缺 — src/services/lsp/LSPServerManager.ts:66 openedFiles: Map<string,string> 无 LRU 无 max, 仅 shutdown/closeFile/closeFilesNotIn 删, 压缩间无界增长
fileReadCache 16MB ⬜ 缺 — src/utils/fileReadCache.ts:16 仅 entry-count cap (1000), 无字节 cap, 1000×10MB=10GB 风险

本 issue 范围

补两处真 gap (MCP stderr 已 cap, 不动):

  1. LSP open-docs 50 上限: LSPServerManager.openFile() set 前, 若 openedFiles.size >= 50, 淘汰最旧 (Map 插入序首项) 经 closeFile() 发 didClose 释放。LRU 近似 (与 fileReadCache FIFO 风格一致)。
  2. fileReadCache 16MB 字节上限: fileReadCache.ts 加 maxCacheBytes = 16 * 1024 * 1024, 累积字节超限触发 10% 批淘汰 (复用现有 entry-count 淘汰路径, 合并判断)。

验收

Co-Authored-By: Claude Fable 5 [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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