-
Notifications
You must be signed in to change notification settings - Fork 37.2k
fix pty output make main process oom #285419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1103,7 +1103,14 @@ export namespace ProxyChannel { | |
| disableMarshalling?: boolean; | ||
| } | ||
|
|
||
| export interface ICreateServiceChannelOptions extends IProxyOptions { } | ||
| export interface ICreateServiceChannelOptions extends IProxyOptions { | ||
| /** | ||
| * If an event is triggered automatically but may not have subscribers, | ||
| * then `isLazyEvent` should return `true`. Otherwise the event data will | ||
| * be cached in the buffer which causing a memory leak | ||
| */ | ||
| isLazyEvent?: (key: string) => boolean; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am reading this comment and fail to understand what actually happens when I use this option. If I understand correctly, a "lazy" event will not buffer any data until a first listener is added. But then I would update this comment to actually explain this better. And should be called differently?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I have updated the comment, please help review again . |
||
| } | ||
|
|
||
| export function fromService<TContext>(service: unknown, disposables: DisposableStore, options?: ICreateServiceChannelOptions): IServerChannel<TContext> { | ||
| const handler = service as { [key: string]: unknown }; | ||
|
|
@@ -1117,6 +1124,9 @@ export namespace ProxyChannel { | |
| const mapEventNameToEvent = new Map<string, Event<unknown>>(); | ||
| for (const key in handler) { | ||
| if (propertyIsEvent(key)) { | ||
| if (options?.isLazyEvent?.(key)) { | ||
| continue; | ||
| } | ||
| mapEventNameToEvent.set(key, Event.buffer(handler[key] as Event<unknown>, true, undefined, disposables)); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1212,7 +1212,9 @@ export class CodeApplication extends Disposable { | |
| sharedProcessClient.then(client => client.registerChannel('profileStorageListener', profileStorageListener)); | ||
|
|
||
| // Terminal | ||
| const ptyHostChannel = ProxyChannel.fromService(accessor.get(ILocalPtyService), disposables); | ||
| const ptyHostChannel = ProxyChannel.fromService(accessor.get(ILocalPtyService), disposables, { | ||
| isLazyEvent: (key: string) => key === 'onProcessData' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whats the rule here to decide if an event should be lazy? Does this apply to other proxy channels?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for reviewing ! An event should be lazy if it is triggered automatically but may not have subscribers; otherwise, the event data will be cached in the buffer (Event.buffer), causing a memory leak. I only find that
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @theanarkh I think what @bpasero is likely getting at is this should get fixed generically to prevent future leaks like this in the future.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }); | ||
| mainProcessElectronServer.registerChannel(TerminalIpcChannels.LocalPty, ptyHostChannel); | ||
|
|
||
| // External Terminal | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.