W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2010

[whatwg] Define MessagePort.isConnected or MessagePort.ondisconnect

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 16 Mar 2010 04:32:59 +0000 (UTC)
Message-ID: <Pine.LNX.4.64.1003160432060.10462@ps20323.dreamhostps.com>
On Mon, 15 Mar 2010, ATSUSHI TAKAYAMA wrote:
> >
> > If you don't need to ever broadcast something to all the ports, you can
> > avoid keeping track of the ports altogether, and then you won't have a
> > problem. If you do need to broadcast, it's hard not to slowly leak at the
> > moment.
> 
> Even with the example below, "port" and "port.onmessage" will be
> created every time I reload the tab, and they will never be cleaned as
> long as I don't close all the pages.
> 
> === <JS> ==
> onconnect = function(e) {
>   var port = e.ports[0];
>   port.onmessage = function() {
>     port.postMessage('yes');
>   }
> }
> === </JS> ==

In the example above, 'port' will be garbage collected once the 
corresponding page has been closed, even if the shared worker continues.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 15 March 2010 21:32:59 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:21 UTC