Skip to content

Define GC for workers in more detail #2553

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

Open
annevk opened this issue Apr 18, 2017 · 4 comments
Open

Define GC for workers in more detail #2553

annevk opened this issue Apr 18, 2017 · 4 comments

Comments

@annevk
Copy link
Member

annevk commented Apr 18, 2017

Currently a worker tracks MessagePort objects. It should probably track BroadcastChannel objects too, otherwise you can observe GC to some approximation.

cc @smaug---- @wanderview

@smaug----
Copy link

I'd say open BroadcastChannel should keep worker alive. If I read the code right, that is happening in Gecko currently, there is a "WorkerHolder" in BroadcastChannel.

@bakulf

@annevk annevk changed the title Should BroadcastChannel keep a worker alive? Define GC for workers in more detail Apr 19, 2017
@annevk
Copy link
Member Author

annevk commented Apr 19, 2017

@bakulf wrote in #1004:

GC behavior is not observable: workers are terminated when there are no APIs keeping them alive for some networking (XHR, WebSocket), cross-thread event listeners (MessagePort, BroadcastChannel, etc) or pending async operations, and, of course, if there is not JS code running.

This could be consider an internal optimization also if not part of the spec.

Some of this is explicitly part of the standard, such as MessagePort. We should probably formalize all this a bit better or just claim they cannot be GC'd and stay alive for the duration of their owner(s).

@bakulf
Copy link

bakulf commented Apr 21, 2017

@SmauG you are right. BroadcastChannel, in gecko, keeps workers alive as well as MessagePort.

@bakulf
Copy link

bakulf commented Apr 21, 2017

@annevk, in case that BroadcastChannel behavior is not covered by the spec, we should file an issue.
We should have a similar section for BroadcastChannel: https://html.spec.whatwg.org/multipage/comms.html#ports-and-garbage-collection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants