On 3/19/14 4:39 PM, Kyle Huey wrote:

We are discovering a lot of leaks in JS implemented DOM objects.  The
general pattern seems to be that we have a DOM object that also needs
to listen to events from the message manager or notifications from the
observer service, which usually hold strong references to the
listener.

This little hack works for the observer service:

http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser-plugins.js#1226

It uses a weak reference with the observer service, plus a dummy strong reference (via addEventListener()) to automatically manage the lifetime... When the node/document does away, so does the event listener.

Dunno if the message manager has a way to do this, but perhaps it wouldn't be hard to add. That it, it's kind of a hack and a cleaner solution would be nice.

Justin
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to