fix: 修复长时间使用导致的内存泄露与崩溃问题 - #453
Open
J3n5en wants to merge 2 commits into
Open
Conversation
- Monaco: 关闭 tab / commit diff 重挂载时正确 dispose model - 编辑器切换 worktree 时卸载非 dirty 内容,切回按需重读 - 删除 worktree 时清理会话/活动/任务等 store 及持久化残留 - xterm/AgentTerminal 定时器与监听器成对清理 - Claude Bridge 关闭时终止 WS 连接,请求体与缓存加上限 - Windows PTY 激活前缓冲、CLI 输出缓冲加上限 - gitServices/worktreeServices 改为 LRU,释放关闭窗口的引用 - 新增崩溃观测:render/child-process-gone 日志与本地 minidump Co-authored-by: Cursor <cursoragent@cursor.com>
- Todo store 新增 unloadRepo,仓库从工作区移除时释放内存缓存 - expandedFolders 按 worktree/子模块分桶存储,互不干扰 - 删除 worktree / 临时工作区时同步清理对应展开状态 Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
修复用户反馈的「长时间使用后内存持续增长、最终崩溃」问题。经排查,主因是渲染进程多处无界内存增长导致 OOM,PTY 原生层此前已有较完善防护。
渲染进程(OOM 主因)
DiffViewer的 commit diff 清理逻辑写在onMount返回值里(库不会调用,属死代码),且keepCurrent*关闭了库的默认释放——浏览提交历史时每个文件 diff 永久泄露 2 个 model;EditorArea关闭 tab 从不 dispose model。两处均已改为正确的生命周期释放agentTasks辅助记录随会话集合自动收敛;agentStatus加上限(全局 hook 会收到任意 Claude 会话的状态)useXterm的 flush 定时器与compositionend监听器成对清理,防止写入已 dispose 的终端;AgentTerminal、MergeEditor等补齐useSharedFileWatch顺带修复同目录多订阅者只有第一个能收到事件的 bug主进程
dispose时终止已连接的 WebSocket;/agent-hook、/status-line请求体加 1MB 上限;节流 Map 加 TTLexecInPty/code review 输出缓冲加上限gitServices/worktreeServices改为 LRU;GitAutoFetch/AutoUpdater 孤儿定时器收口;窗口关闭时释放 BrowserWindow 引用FileWatcher防重入崩溃观测(新增)
render-process-gone/child-process-gone写入日志(可区分oom与原生崩溃),渲染进程崩溃后自动 reload(10 秒防循环)crashReporter保留本地 minidump其他
Test plan
pnpm typecheck通过pnpm test与 main 基线一致(8 个既有失败均为 macOS 上运行 Windows 路径断言,与本次改动无关)monaco.editor.getModels()数量不再单调增长Made with Cursor