Skip to content

fix: memory leak in ipc#293913

Open
SimonSiefke wants to merge 5 commits intomicrosoft:mainfrom
SimonSiefke:fix/memory-leak-ipc-1
Open

fix: memory leak in ipc#293913
SimonSiefke wants to merge 5 commits intomicrosoft:mainfrom
SimonSiefke:fix/memory-leak-ipc-1

Conversation

@SimonSiefke
Copy link
Copy Markdown
Contributor

Fixes a memory leak in ipc.

Details

In ipc in the onDidClientConnect callback, two disposables are registered to this.disposables:

  1. this.disposables.add(onFirstMessage(msg => {
  2. this.disposables.add(onDidClientDisconnect(() => {

When a client connects and then disconnects, the disposables registered by 1. and 2. don't seem to be disposed.

Example: When a new window is opened and closed, first the window client connects onDidClientConnect, then onFirstMessage and the onDidClientDisconnect listeners are set up. When the window is closed, onDidClientDisconnect fires. But the onFirstMessage and onDidClientDisconnect are not removed, only when the IPCServer disposes.

Change

The change is not adding the disposables 1. and 2. to this.disposables. But instead to a separate connectionDisposable. The connectionDisposable is disposed when the client disconnects.

That way, when a client connects and disconnects, no extra disposables remain in this.disposables

Before

When opening and closing a window 17 times, the number of ChannelClient, ChannelServer and IpcMain functions seems to grow each time:

shapes at 26-02-09 17 00 05

After

When opening and closing a window 17 times, the number of ChannelClient, ChannelServer and IpcMainImpl functions stays constant:

window-open-new

Copilot AI review requested due to automatic review settings February 9, 2026 16:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@vs-code-engineering
Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@bpasero

Matched files:

  • src/vs/base/parts/ipc/common/ipc.ts

Copy link
Copy Markdown
Member

@joaomoreno joaomoreno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 👏

@joaomoreno joaomoreno added this to the 1.113.0 milestone Mar 16, 2026
@joaomoreno joaomoreno modified the milestones: 1.113.0, Backlog Mar 24, 2026
@joaomoreno joaomoreno enabled auto-merge (squash) March 24, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants