[whatwg] WebSocket: garbage collection

Simon Pieters simonp at opera.com
Thu May 6 08:20:41 PDT 2010


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


More information about the whatwg mailing list