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

[whatwg] WebSocket: garbage collection

From: Simon Pieters <simonp@opera.com>
Date: Thu, 06 May 2010 17:20:41 +0200
Message-ID: <op.vcah8rk9idj3kv@simon-pieterss-macbook.local>
On Tue, 20 Apr 2010 16:00:36 +0200, Simon Pieters <simonp at opera.com> wrote:

> [[
> WebSocket object with an open connection must not be garbage collected  
> if there are any event listeners registered for message events.
> ]]
>
> Shouldn't it also not be garbage collected if there are listeners for  
> open, error and close? What about when the connection is not yet  
> established?

I think the policy should be:

if readyState is CONNECTING:
   has 'open' event listener: don't collect
   has 'message' event listener: don't collect
   has 'error' event listener: don't collect
   has 'close' event listener: don't collect

if readyState is OPEN:
   has 'open' event listener: OK to collect
   has 'message' event listener: don't collect
   has 'error' event listener: don't collect
   has 'close' event listener: don't collect

if readyState is CLOSING:
   has 'open' event listener: OK to collect
   has 'message' event listener: OK to collect
   has 'error' event listener: OK to collect
   has 'close' event listener: don't collect

if readyState is CLOSED:
   has 'open' event listener: OK to collect
   has 'message' event listener: OK to collect
   has 'error' event listener: OK to collect
   has 'close' event listener: OK to collect

-- 
Simon Pieters
Opera Software
Received on Thursday, 6 May 2010 08:20:41 UTC

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