Le 01/11/2013 19:34, Andrew McCreight a écrit :
3. Finally, though I'm generally opposed to weak references, as they are 
complex to implement, I do understand that there's a need for them.  When 
working on the leaks in bug 893012, to fix some of the individual leaks, like 
bug 894147, we had to use weak references.
Can you provide more details on why you *had* to use weak refs?

You have iframes that want to listen to events, so the event listener has to 
hold onto the iframe
Why so?

    function f(e){}

    (function(){
        var iframe = document.getElementByTagName('iframe')[0];
        iframe.addEventListener('someEvent', f);
    })()

In this case, f doesn't hold a reference to anything besides itself, not to the iframe at least. In the case of DOM events, it can look at its argument to find e.target which will dynamically (!), only for the time of the listener call, refer to the iframe.

In any case, when an event doesn't need to be listened to anymore, there is a time in your application where you can remove the listener. The leak is not removing the listener, not the listener itself.

So it feels a little crummy to say "hey B2G shows that JS is good enough for 
everything!" if you have to choose between leaking or using web-legal JS.
+1

David
_______________________________________________
dev-tech-js-engine-internals mailing list
dev-tech-js-engine-internals@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to