[whatwg] Define MessagePort.isConnected or MessagePort.ondisconnect

Ian Hickson ian at hixie.ch
Mon Mar 15 21:32:59 PDT 2010


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.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list