[whatwg] Collection garbage on WebSockets

Simon Pieters simonp at opera.com
Mon Jun 28 07:28:17 PDT 2010

On Mon, 28 Jun 2010 16:14:11 +0200, Wellington Fernando de Macedo  
<wfernandom2004 at gmail.com> wrote:

> Hi,
> The WebSockets API spec states:
> "A WebSocket  object with an open connection must not be garbage  
> collected if there are any event listeners registered for message  
> events."
> The Mozilla's implementation, however, also keeps alive the object if it  
> has any
> event listeners registered for open events. We are calling
> them (the message and open events) as 'strong' events. You can read the
> discussion about that in comments #5, #6 and #9 of:
> https://bugzilla.mozilla.org/show_bug.cgi?id=572975
> Now, there has been raised two more possibilities in the discussion (from
> comment #48):
>   * When there are not sent outgoing messages;

That's a case I hadn't considered. I think it shouldn't be collected.

>   * When at least one open or message events has been received, and  
> there are
> close events listeners (the close event could be flagged as 'strong' in  
> this
> case);

You can get close event without an open event first. (I don't think  
Firefox gets this right currently.)

> We, from Mozilla, would like to know what do you think about that, if it  
> makes
> sense or not.
> Thanks!
> Regards,

Also see  
(we have implemented this policy).

Simon Pieters
Opera Software

More information about the whatwg mailing list