[whatwg] Worker lifecycle
ian at hixie.ch
Thu May 28 13:08:05 PDT 2009
On Thu, 28 May 2009, Maciej Stachowiak wrote:
> I'm assuming this is one of the changes:
> > User agents must either act as if MessagePort objects have a strong
> > reference to their entangled MessagePort object or as if each
> > MessagePort object's owner has a strong reference to the MessagePort
> > object.
> It seems to me the second alternative prevents MessagePorts created by a
> Window from ever being garbage collected until the user leaves the page.
> Is that a correct understanding?
> If so, that seems like it could create unbounded memory leaks in
> long-running Web applications that use MessagePorts, even if all
> references to both endpoints of the MessageChannel are dropped. That
> seems unacceptable to me, unless I misunderstood.
The requirement is actually indistinguishable from the UA using the other
alternative and just having a really slow garbage collector that only runs
at page-closing time.
On Thu, 28 May 2009, Drew Wilson wrote:
> Is your concern that an ill-behaved app could leak ports (since
> obviously an ill-behaved app could leak ports anyway just by stuffing
> them in some array), or is it that a well-behaved app can't release
> ports? Still need to review the new spec in detail, but from previous
> conversations I'd assumed that calling MessagePort.close() on either end
> would allow the ports to be freed - perhaps we should clarify the
> language in the spec to state that the strong reference is only in place
> for *entangled* ports.
The UA can at any time switch to the other mechanism, which only has a
strong reference through the entanglement, which basically means that the
UA can be as aggressive as the UA wants to be.
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg