Skip to content

fix: memory leak in policy ipc#96

Closed
SimonSiefke wants to merge 4 commits intomainfrom
fix/memory-policy-ipc
Closed

fix: memory leak in policy ipc#96
SimonSiefke wants to merge 4 commits intomainfrom
fix/memory-policy-ipc

Conversation

@SimonSiefke
Copy link
Copy Markdown
Owner

@SimonSiefke SimonSiefke commented Feb 9, 2026

Fixes a memory leaks in policy ipc.

Details

There exists only one PolicyChannelServer and multiple PolicyChannelClients. Currenly, when a client listens, an event disposable gets the PolicyChannelServer disposables. But it doesn't seem to be removed when the client disconnects or gets disposed.

listen(_: unknown, event: string): Event<any> {
	switch (event) {
		case 'onDidChange': return Event.map(
			this.service.onDidChange,
			names => names.reduce<object>((r, name) => ({ ...r, [name]: this.service.getPolicyValue(name) ?? null }), {}),
			this.disposables // here
		);
	}
}

Change

By moving the _onDidChange event creation to the constructor, the event disposables are only added once to this.disposables. When a client listens, disposables are added to this.disposables.

Before

When opening and closing a window 17 times, the number of functions in PolicyChannel.listen seems to grow each time:
shapes at 26-02-09 18 52 55

After

When opening and closing a window 17 times, the number of functions in PolicyChannel.listen stays constant:

window-open-new

@SimonSiefke SimonSiefke closed this Feb 9, 2026
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