GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — fix(bash): memory leak - release parsed syntax trees by Hona · Pull Request #24861 · anomalyco/opencode Conversation
|
| mode | external start | external end | result |
|---|---|---|---|
no tree.delete() |
~69 MB | ~3.7 GB | leaks |
with tree.delete() |
~69 MB | ~66 MB | stable |
RSS also climbed in the no-delete run, while the delete run stayed stable after initial parser setup.
web-tree-sitter exposes Tree.delete() and its JS implementation calls _ts_tree_delete; it does not rely on a visible JS finalizer. The old code returned only tree.rootNode, so the Tree handle was dropped without releasing the underlying WASM/native tree allocation.
This change returns the Tree, uses tree.rootNode while scanning permissions, and releases the tree before running the shell command.
bun typecheck from packages/opencodebun turbo typecheck
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PR addresses a memory leak in the bash permission-scanning path by ensuring web-tree-sitter parse trees are explicitly released after scanning completes.
Changes:
parse() to return the Tree instead of tree.rootNode so the tree handle remains available for cleanup.collect + ask) in Effect.scoped with Effect.acquireRelease to call tree.delete() reliably (including on failure/interruption).💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: jiwenshang <[email protected]>
71baf86 to
f100217
Compare
There was an error while loading. Please reload this page.
Co-authored-by: jiwenshang <[email protected]>
Co-authored-by: jiwenshang <[email protected]>
将 upstream/dev (38adc13) 合并到 dev-custom,解决 14 个文件的合并冲突, 同时修复因上游模块迁移导致的构建错误。构建与 Smoke Test 全部通过。 ## 上游主要更新 - **HttpApi 后端重构与完整测试覆盖**:authorization middleware、instance context、 workspace routing、websocket proxy、SDK parity、Effect HttpApi backend parity。 - **桌面端修复**:路径匹配导致 sessions 丢失、强 ID、现有数据修复 (anomalyco#25013)。 - **模型支持**:新增 Mistral Medium 3.5 with reasoning (anomalyco#24996)。 - **参数调整**:Azure/DeepSeek 默认参数优化;系统提示词顺序调整为 Global → Project → Skills。 - **Session 路径**:新增按路径过滤 session 及禁用设置 (anomalyco#24849);数据库新增 session_path、 icon_url_override 字段。 - **TUI 体验**:粘贴摘要开关更易用 (anomalyco#24869)。 - **内存泄漏修复**:Bash 工具释放解析后的语法树 (anomalyco#24861)。 - **MCP 健壮性**:无效 MCP URL 处理修复 (anomalyco#25019)。 - **核心模块迁移**:global、filesystem、flag、log、npm、effect 等大量底层模块从 packages/opencode 迁移到 packages/core,建立更清晰的分层。 - **版本同步**:v1.14.30。 ## 本地定制功能保全 以下本地特有功能在合并中完全保全,未受上游更新影响: - **StrategyLoops 轻量框架**:StrategyLoops/ 目录下 PEE/MPEE 模块、Role/Session 管理、 opencode 适配器等全部保留。 - **可配置存储路径**:database、log、worktree、snapshot 路径支持环境变量与配置文件自定义。 - **日志系统增强**:log-tee 模式(同时输出到文件与控制台)、可配置日志目录。 - **Snapshot 优化**:使用本地 ignore 库替代 git check-ignore,避免 Windows ENAMETOOLONG; 文件夹级忽略的批量删除逻辑完整保留。 - **MCP 面板项目名提示**:status-popover-body.tsx 中当前项目名展示保留。 - **设置页路径展示**:settings-general.tsx 中 worktree/snapshot/config 路径加载与展示保留。 - **分叉版本构建工作流**、中文贡献文档、定制 i18n 键等全部保留。 ## 冲突解决与代码整合 | 文件 | 冲突处理策略 | |------|-------------| | dialog-edit-project.tsx | 采用上游提取的 getProjectAvatarSource() 函数,同时保留本地 override/url/color 完整逻辑 | | sidebar-items.tsx / layout.tsx | 整合上游头像来源逻辑,保留本地 icon override 与 color 判定 | | settings-general.tsx | 保留本地 loadConfigFiles / loadWorktreeInfo / loadSnapshotInfo 及路径展示 UI;合并上游新增的 shell / displayBackend 等逻辑 | | status-popover-body.tsx | 保留本地 projectName 提示;去除上游删除的废弃 load 状态 | | config/config.ts | 采纳上游 Schema 修正(ConfigAgent.Info 替换 AgentRef;MCP 禁用配置改用 Schema.Struct) | | server/event.ts | 保留本地 ConfigUpdated 事件定义,同时合并上游 Schema 化改造 | | server/routes/global.ts | 完整保留本地特有的 /storage/* 与 /config/path 路由;合并上游模块导入路径重构 | | snapshot/index.ts | 修正导入路径到 @opencode-ai/core/*,保留本地 ignore 库、StorageConfig、Flag 等全部定制 | | worktree/index.ts | 同上,修正模块路径,保留本地 StorageConfig / Flag / resolveDir 等定制 | ## 构建修复(模块迁移适配) 上游将 global、flag 等模块迁移到 packages/core 后,本地定制代码出现模块解析失败: 1. **StorageConfig 跨包迁移**:将 storage-config.ts 从 opencode 包迁移到 packages/core/src/storage/storage-config.ts,原位置改为重新导出;解除 core → opencode 的反向依赖,避免循环依赖。 2. **依赖补充**:core/package.json 新增 jsonc-parser 依赖(原仅在 opencode 中声明)。 3. **导入路径修正**:core/src/util/log.ts、snapshot/index.ts、worktree/index.ts 中的 ../global、../flag/flag、../storage/storage-config 等相对路径统一修正为 @opencode-ai/core/* 路径。
Co-authored-by: jiwenshang <[email protected]>
Co-authored-by: jiwenshang <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[BUG]: bash tool memory leak
There was an error while loading. Please reload this page.