Skip to content

Commit

Permalink
Fix process reuse leak on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 committed Apr 15, 2021
1 parent 7d62d6a commit 916d63f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ export class LocalProcessExtensionHost implements IExtensionHost {

this._toDispose.add(this._onExit);
this._toDispose.add(this._lifecycleService.onWillShutdown(e => this._onWillShutdown(e)));
this._toDispose.add(this._lifecycleService.onDidShutdown(reason => this.terminate()));
this._toDispose.add(this._extensionHostDebugService.onClose(event => {
if (this._isExtensionDevHost && this._environmentService.debugExtensionHost.debugId === event.sessionId) {
this._nativeHostService.closeWindow();
Expand Down Expand Up @@ -622,21 +621,11 @@ export class LocalProcessExtensionHost implements IExtensionHost {
}

this._messageProtocol.then((protocol) => {

// Send the extension host a request to terminate itself
// (graceful termination)
protocol.send(createMessageOfType(MessageType.Terminate));

protocol.dispose();

// Give the extension host 10s, after which we will
// try to kill the process and release any resources
setTimeout(() => this._cleanResources(), 10 * 1000);

}, (err) => {

// Establishing a protocol with the extension host failed, so
// try to kill the process and release any resources.
}).finally(() => {
this._cleanResources();
});
}
Expand Down Expand Up @@ -664,5 +653,6 @@ export class LocalProcessExtensionHost implements IExtensionHost {
this._extensionHostDebugService.terminateSession(this._environmentService.debugExtensionHost.debugId);
event.join(timeout(100 /* wait a bit for IPC to get delivered */), 'join.extensionDevelopment');
}
this.terminate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { FileAccess } from 'vs/base/common/network';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';

export class LocalSearchService extends SearchService {
constructor(
Expand Down Expand Up @@ -54,6 +55,7 @@ export class DiskSearch implements ISearchResultProvider {
searchDebug: IDebugParams | undefined,
@ILogService private readonly logService: ILogService,
@IConfigurationService private readonly configService: IConfigurationService,
@ILifecycleService private readonly lifecycleService: ILifecycleService
) {
const timeout = this.configService.getValue<ISearchConfiguration>().search.maintainFileSearchCache ?
100 * 60 * 60 * 1000 :
Expand Down Expand Up @@ -84,6 +86,10 @@ export class DiskSearch implements ISearchResultProvider {
const client = new Client(FileAccess.asFileUri('bootstrap-fork', require).fsPath, opts);
const channel = getNextTickChannel(client.getChannel('search'));
this.raw = new SearchChannelClient(channel);

this.lifecycleService.onDidShutdown(() => {
client.dispose();
});
}

textSearch(query: ITextQuery, onProgress?: (p: ISearchProgressItem) => void, token?: CancellationToken): Promise<ISearchComplete> {
Expand Down

0 comments on commit 916d63f

Please sign in to comment.