-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11583 from Microsoft/joh/11455
Joh/11455
- Loading branch information
Showing
12 changed files
with
154 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
declare module 'gc-signals' { | ||
export interface GCSignal { | ||
} | ||
/** | ||
* Create a new GC signal. When being garbage collected the passed | ||
* value is stored for later consumption. | ||
*/ | ||
export const GCSignal: { | ||
new (id: number): GCSignal; | ||
}; | ||
/** | ||
* Consume ids of garbage collected signals. | ||
*/ | ||
export function consumeSignals(): number[]; | ||
export function onDidGarbageCollectSignals(callback: (ids: number[]) => any): { | ||
dispose(): void; | ||
}; | ||
export function trackGarbageCollection(obj: any, id: number): number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
import {ExtHostHeapServiceShape} from './extHost.protocol'; | ||
|
||
export class ExtHostHeapService extends ExtHostHeapServiceShape { | ||
|
||
private static _idPool = 0; | ||
|
||
private _data: { [n: number]: any } = Object.create(null); | ||
private _callbacks: { [n: number]: Function } = Object.create(null); | ||
|
||
keep(obj:any, callback?:() => any): number { | ||
const id = ExtHostHeapService._idPool++; | ||
this._data[id] = obj; | ||
if (typeof callback === 'function') { | ||
this._callbacks[id] = callback; | ||
} | ||
return id; | ||
} | ||
|
||
delete(id: number): boolean { | ||
delete this._callbacks[id]; | ||
return this._data[id]; | ||
} | ||
|
||
get<T>(id: number): T { | ||
return this._data[id]; | ||
} | ||
|
||
$onGarbageCollection(ids: number[]): void { | ||
for (const id of ids) { | ||
setTimeout(this._callbacks[id]); | ||
this.delete(id); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
'use strict'; | ||
|
||
import {IDisposable} from 'vs/base/common/lifecycle'; | ||
import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; | ||
import {ExtHostContext} from './extHost.protocol'; | ||
import {onDidGarbageCollectSignals, consumeSignals} from 'gc-signals'; | ||
|
||
export class MainThreadHeapService { | ||
|
||
private _subscription: IDisposable; | ||
private _consumeHandle: number; | ||
|
||
constructor( @IThreadService threadService: IThreadService) { | ||
const proxy = threadService.get(ExtHostContext.ExtHostHeapService); | ||
|
||
this._subscription = onDidGarbageCollectSignals(ids => { | ||
proxy.$onGarbageCollection(ids); | ||
}); | ||
|
||
this._consumeHandle = setInterval(consumeSignals, 15 * 1000); | ||
} | ||
|
||
dispose() { | ||
clearInterval(this._consumeHandle); | ||
this._subscription.dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters