Re: [whatwg] BroadcastChannel memory leak

On Fri, May 23, 2014 at 5:54 PM, Michael Nordman <michaeln@google.com> wrote:
>> When is it safe for a user agent to garbage collect a BroadcastChannel
>> instance?
>
> When there's no direct reference to the object and no onmessage handler
> attached to it. (?)

That doesn't play nicely with anonymous JavaScript functions that
can't ever be removed as event listeners...

Adam


> On Fri, May 23, 2014 at 5:23 PM, Adam Barth <w3c@adambarth.com> wrote:
>>
>> When is it safe for a user agent to garbage collect a BroadcastChannel
>> instance?
>>
>>
>> http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#broadcasting-to-other-browsing-contexts
>>
>> Given that another document might create a new BroadcastChannel
>> instance at any time, the |message| event of the object might fire any
>> time its responsible document is fully active.  For web application
>> that have long-lived documents, the BroadcastChannel might not be
>> eligible for garbage collection for a long time.
>>
>> Proposal: Add a |close| method to the BroadcastChannel interface
>> similar to the |close| method on MessagePort.  The |close| method
>> would just neuter the instance of the channel and prevent it from
>> receiving further messages.
>>
>> Adam
>
>

Received on Saturday, 24 May 2014 01:08:57 UTC