Re: [whatwg/dom] Should DOM provide guidance on garbage collection of EventTarget instances? (#1003)

In Blink this concept is embodied by the `ActiveScriptWrappable` interface, which has a `HasPendingActivity()` method that can return `true` to indicate that the object shouldn't be garbage collected even if it appears to be garbage. Implementing custom logic here is how interfaces like [`WebSocket`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/websockets/dom_websocket.cc;l=493;drc=b7519d27331ea741d0b2463569ee538b8b287dbb) extend their lifetimes. In that case you're right, Blink does it based on whether the connection is still active and not the presence of event listeners. Maybe it should as that would allow the connection to be closed if it were no longer possible for script to send or receive messages from it. These decisions definitely result in behavior which is visible to developers and so while I think overall engines have done the "obvious" thing to avoid bugs it should probably be specified more precisely.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1003#issuecomment-892111635

Received on Tuesday, 3 August 2021 19:37:44 UTC