Skip to content

feat(cli,vscode): add memory profiling infrastructure for kilo serve#8982

Draft
marius-kilocode wants to merge 1 commit intomainfrom
tropical-joke
Draft

feat(cli,vscode): add memory profiling infrastructure for kilo serve#8982
marius-kilocode wants to merge 1 commit intomainfrom
tropical-joke

Conversation

@marius-kilocode
Copy link
Copy Markdown
Collaborator

@marius-kilocode marius-kilocode commented Apr 15, 2026

Don't review this, only to profile memory issues on Windows

Summary

  • Adds KILO_PROFILE=1 env flag and --profile option to bun run extension that enables memory profiling of the kilo serve backend process
  • Adds HTTP debug endpoints (/global/debug/memory, /global/debug/snapshot, /global/debug/gc) for on-demand memory inspection and heap snapshot capture
  • Adds periodic memory logging (every 30s) when profiling is enabled
  • Includes documentation at packages/kilo-vscode/docs/infrastructure/memory-profiling.md covering the full profiling workflow, suspected causes, and analysis techniques

This is investigative tooling for the Windows memory leak where the Bun process accumulates multiple GB of RSS over extended Agent Manager usage with large worktree diffs. The doc describes what we know so far (RSS grows outside V8 heap, pointing to native buffer accumulation from git stdout buffering) and how to reproduce/measure it.

Add KILO_PROFILE flag gating debug HTTP endpoints and periodic memory
logging on the kilo serve backend. This enables investigating memory
leaks that occur when the Agent Manager is used over extended periods,
particularly on Windows with large worktree diffs.

- GET /global/debug/memory — current process.memoryUsage() stats
- POST /global/debug/snapshot — write V8 heap snapshot to disk
- POST /global/debug/gc — force GC and report before/after
- 30s periodic memory logging when KILO_PROFILE=1
- --profile flag on bun run extension to enable everything
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Apr 15, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (6 files)
  • packages/kilo-vscode/docs/infrastructure/memory-profiling.md
  • packages/kilo-vscode/script/launch.ts
  • packages/kilo-vscode/src/services/cli-backend/server-manager.ts
  • packages/opencode/src/cli/heap.ts
  • packages/opencode/src/flag/flag.ts
  • packages/opencode/src/server/routes/global.ts

Reviewed by gpt-5.4-2026-03-05 · 616,101 tokens

@marius-kilocode marius-kilocode marked this pull request as draft April 15, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant