Skip to content

fix: memory leak in TerminalCodeExecutionProvider - #2

Draft
SimonSiefke wants to merge 1 commit into
mainfrom
fix/memory-leak-terminalCodeExecution
Draft

SimonSiefke wants to merge 1 commit into
mainfrom
fix/memory-leak-terminalCodeExecution

Conversation

@SimonSiefke

Copy link
Copy Markdown
Owner

Details

TerminalCodeExecutionProvider adds a close listener each time a Python REPL starts. The listener and its subscription stay in the session disposal registry after the terminal closes.

Change

Dispose the close listener when its REPL closes, and keep one session cleanup handler for the active listener.

Before

When starting, running code in, and closing a Python REPL 17 times, its close callbacks in the extension host grow by 17:

before

After

No more leak detected.

Test Video

video.webm

AI disclosure: Model: GPT 6.1 Sol. Worktime: 12 min

@SimonSiefke

Copy link
Copy Markdown
Owner Author

[ai-review] Review overview

🟡 Review feedback

Findings: None. At 4a629c0317e569e07cb4c3f0da566844be9ef1f5, the scoped Linux REPL leak reproduced before the fix and stopped accumulating afterward. Across 17 measured extension-host iterations, close callbacks changed 2→19 on baseline versus 0→0 on candidate; SynchronousTerminalService counts changed 3→20 versus 2→2. These are exact counts from preserved heaps, beyond the filtered leak threshold.

Full validation remains incomplete: the supplemental baseline Run Selection scenario did not create its expected result file, leaving matched selection and latency checks unverified. Windows/full native Electron CI was not executed. The VS Code-core review/audit skills are absent from this extension repository, limiting certification of that adapted workflow.

Validation and review details

Independent full static reviews: gpt-6-astra / max and gpt-6.1-sol / max; no introduced defect or test race found. Initial discussion contained no earlier feedback.

Baseline/candidate native units: 157 / 159 passing. Root/API TypeScript checks, focused ESLint and formatting checks passed. The new close-lifetime test fails against baseline as expected. Native diagnostics also verified repeated active reuse, pending-start close/reopen, session disposal, and bounded listener/registry ownership.

Both original real-UI smokes passed; matched measurements used VS Code 1.143.1, two warmups and 17 measured create/execute/close cycles per side. Candidate had zero filtered leak rows, and bounded raw-heap analysis confirmed both target deltas were zero. Accepted extension-host logs had no errors; source remained unchanged.

Next checks: diagnose the supplemental baseline selection fixture, complete matched adjacent/performance acceptance, and run Windows/native integration coverage. Missing core-specific skills are a portability limitation, not a product defect.

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