Improving Function.prototype.bind

Mark S. Miller erights at google.com
Sun Jan 8 17:05:21 PST 2012


On Sun, Jan 8, 2012 at 3:35 PM, Brendan Eich <brendan at mozilla.com> wrote:
[...]

>  That's not totally clear now in light of Mark's emulated WeakMap not
> leaking in practice.
>
[...]

That's a much stronger claim than I would be willing to make. My emulated
WeakMaps leak much less that one would expect, and indeed less than I
thought possible when I began the exercise. But the remaining extra leak is
still significant for real uses.

>From <http://code.google.com/p/es-lab/source/browse/trunk/src/ses/WeakMap.js
>:

/**
 * This {@code WeakMap} emulation is observably equivalent to the
 * ES-Harmony WeakMap, but with leakier garbage collection properties.
 *
 * <p>As with true WeakMaps, in this emulation, a key does not
 * retain maps indexed by that key and (crucially) a map does not
 * retain the keys it indexes. A map by itself also does not retain
 * the values associated with that map.
 *
 * <p>However, the values associated with a key in some map are
 * retained so long as that key is retained and those associations are
 * not overridden. For example, when used to support membranes, all
 * values exported from a given membrane will live for the lifetime
 * they would have had in the absence of an interposed membrane. Even
 * when the membrane is revoked, all objects that would have been
 * reachable in the absence of revocation will still be reachable, as
 * far as the GC can tell, even though they will no longer be relevant
 * to ongoing computation.




-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120108/606ac193/attachment-0001.html>


More information about the es-discuss mailing list