On 18/09/2013, at 09:25, Gene Lian wrote:
> The above two make much sense to me! If the messages which an object is
> listening for are all for one-shot purpose (i.e. working for a specific
> request/promise), then there is no reason to apply strong reference to avoid
> being GC'ed since there should always be a JS reference waiting for the
> return. However, if we really want to fix all of them, we have to know the
> semantic of all the messages so that you can decide which one should be added
> as strong reference and which one should be added as weak reference. This fix
> probably needs a full understanding of all the API designs, though.
Indeed. We'll need to file bugs for each specific API.
> In the initiative step, I'd prefer fixing this issue from the point of view
> of *object* instead of *request/promise*. Also, as you suggested, we should
> use *strong reference* as the default, unless we're very sure an object
> doesn't need to be kept alive with the window (e.g., WebappsApplication
> objects), then we can use weak reference to register its messages. Therefore,
> the function could be something like:
>
> initDOMRequestHelper(aWindow, aMessages, "weak"/"strong");
>
This is what the WIP at [1] does :)
> In the long term, we need to distinguish the types of messages to have an
> optimized way of using strong/weak references and I'd suggest turning this
> function into something like:
>
> initDOMRequestHelper(aWindow, [{name: XXX, type: "weak"},
> {name: XXX, type: "strong"},
> ...]);
>
> to force the callers to explicitly specify the type of each message.
That sounds like a better option. Thanks!
Cheers,
/ Fernando
[1] https://bugzilla.mozilla.org/show_bug.cgi?id=915598
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g