dojo/aspect leaks memory when removed handles are retained elsewhere
Consider the following:
(function () {
var a = createLargeObject(),
b = function () {};
window.handle = aspect.after(a, 'foo', b);
window.handle.remove();
})();
Even though the handle has been removed, a
and b
continue to be retained through the global reference to the handle object itself as dispatcher
and advice
, which means that any time you use dojo/aspect
without making sure you delete all references to a handle—even if the handle is “removed”—you are leaking potentially huge numbers of objects.
The solution is to simply make sure that all references retained through closures on the returned handle object are nulled out when remove
is called. Users might still leak the handle, but at least it won’t leak all their stuff too.
In [31298]: